These are chat archives for rust-lang/rust

2nd
Oct 2017
Vyacheslav Kim (Kane)
@kanekv
Oct 02 2017 04:15
which plugin do you use for vscode? All I've tried don't really work
Andrey Lesnikov
@ozkriff
Oct 02 2017 04:16
https://github.com/rust-lang-nursery/rls-vscode is the official one. works for me
Vyacheslav Kim (Kane)
@kanekv
Oct 02 2017 04:17
thanks, trying it right now
can it jump to definition in rust stdlib?
Vyacheslav Kim (Kane)
@kanekv
Oct 02 2017 04:22
it seems that doesn't work for me (uses wrong path)
ok, there is open bug: rust-lang-nursery/rls-vscode#110, looks like pretty basic functionality is missing
Andrey Lesnikov
@ozkriff
Oct 02 2017 04:25
Hmmm, I'm sure it was working some time ago. Some kind of regression :(
David DeSimone
@DavidDeSimone
Oct 02 2017 04:27
so I'm using msys2 on windows, and trying to compile and link a rust staticlib (a .lib) to an executable, and I'm getting linker errors saying it can't link __chkstk and ??_7type_info@@6B@. I am passing the flags -ladvapi32 -lkernel32 -ladvapi32 -lws2_32 -luserenv -lshell32 -lmsvcrt to gcc
anyone see anything like this before? My googling gives a lot of seemingly unrelated issues
I'm linking against everything that cargo is telling me to link against
David DeSimone
@DavidDeSimone
Oct 02 2017 05:34
so for anyone curious, it looks like linking against libgcc gives me ___chkstk with 3 underscores, but rand = "0.3" is looking for __chkstk with two underscores. I wrote __chkstk that calls ___chkstk and things seem to be working
lemonxah
@lemonxah
Oct 02 2017 06:39
@weihsiu i might come in a little late and i dont know if you have solved this yet
fn retrieve<T>(&self, key: &str) -> Result<T, String> where for<'a> T : Deserialize<'a> {
    let bs = ...; //retrieve a Vec<u8> somewhere
    Ok(serde_json::from_slice(&bs).unwrap())
}
TatriX
@TatriX
Oct 02 2017 12:54
Any emacs + rls users here?
David Harvey-Macaulay
@alteous
Oct 02 2017 13:40
Only emacs. :frowning:
TatriX
@TatriX
Oct 02 2017 13:42
I almost made it work. It's a pain..
Fra ns
@snarf95_twitter
Oct 02 2017 14:07
vscode + rls is working great for me
TatriX
@TatriX
Oct 02 2017 14:10
I still can't find what rls can do which racer can't. I have no idea if rls even works.
Steve Klabnik
@steveklabnik
Oct 02 2017 14:11
rls talks to the compiler directly to get its info
racer does its own thing
this means that rls can, at least in theory, get much richer understanading, since it knows exactly what the compiler knows
TatriX
@TatriX
Oct 02 2017 14:11
Yeah, it's written in the readme.
Steve Klabnik
@steveklabnik
Oct 02 2017 14:12
that said, it's also under active development
it will work much better once it ships by default
which it's scheduled to soonish
TatriX
@TatriX
Oct 02 2017 14:12
I'm looking for a feature list
Steve Klabnik
@steveklabnik
Oct 02 2017 14:12
TatriX
@TatriX
Oct 02 2017 14:18
Maybe ;) Thanks!
Steve Klabnik
@steveklabnik
Oct 02 2017 14:19
no problem
this is the way things are when they're new and being heavily developed, docs could be way better, it's true
James McCoy
@jamessan
Oct 02 2017 16:59
Then one the profiler tells you is faster?
mnivoliez
@mnivoliez
Oct 02 2017 19:02
Hello
Andrey Lesnikov
@ozkriff
Oct 02 2017 19:09
:wave:
mnivoliez
@mnivoliez
Oct 02 2017 19:40
I implementing a Raytracer in Rust but I'm struggling to some aspect. Here a link to the code: https://gitlab.deep-nope.me/mnivoliez/raytracer/tree/1-remodel-code-to-adt-model/src
I'm feeling like if the structure wasn't right
Also there is a lot of match and vector filters
Maybe a cost of ADT pattern
Can you give me, in look of the code product so far, some leads to enhance all this?
Aleksey Kladov
@matklad
Oct 02 2017 19:48
@mnivoliez one thing I would do is to use trait objects instead of enum for various geometric primitives
mnivoliez
@mnivoliez
Oct 02 2017 19:51
I did that first in master
but the goal si to have an horizontal hierarchy than a vertical one
Aleksey Kladov
@matklad
Oct 02 2017 19:54
What do you mean, "horizontal vs vertical"?
mnivoliez
@mnivoliez
Oct 02 2017 20:00
I was tryinbg to explain from pure OOP perspective, but in this way it's easier. If you use ADT to model you "classes" hierarchy, then the hierachy is finisched and predictable. If you make a trait struct based for each primitives, then either you have to create specific method for them (similar to a new match case) or you have to implement a "Primitives" super trat struct and make concrete prmitive inherit the first one. Thus the hierarchy is virtualy non-finite and thus you can't enforce case checking in the code. Also, you'll have to manage normale calculation, intersection, reflection, etc inside such a trait.
I'm not sure to have found the right words
Alors we are dealing more and more with complexe primitive and properties
Aleksey Kladov
@matklad
Oct 02 2017 20:03
Hm, in my ray tracer, a trait with a singe method worked OK: https://github.com/matklad/rustraytracer/blob/master/libs/geom/src/shape/mod.rs#L62
mnivoliez
@mnivoliez
Oct 02 2017 20:03
Am I making sense?
Aleksey Kladov
@matklad
Oct 02 2017 20:04
But yeah, if you are going to make something completely custom for each primitive, you'll end up adding more and more methods to the trait, which isn't nice.
mnivoliez
@mnivoliez
Oct 02 2017 20:05
The ADT idea is coming from the inheritance mess risk and a bit of help of my teacher
Aleksey Kladov
@matklad
Oct 02 2017 20:06
Well, you can't really use inheritance in Rust even with traits, so I won't be afraid of that :)
mnivoliez
@mnivoliez
Oct 02 2017 20:06
but the truth is, even if the idea is good, I'm not use to this kind of developpement so I kind of struggle to have a propoer organisation.
But my real problem is the beahavior management.
and lights
mnivoliez
@mnivoliez
Oct 02 2017 20:12
@matklad Can I analyse your work to enhance mine? (no copy paste, don't worry)
Aleksey Kladov
@matklad
Oct 02 2017 20:23
sure!
And there's also https://github.com/Twinklebear/tray_rust which is way more advanced :)
mnivoliez
@mnivoliez
Oct 02 2017 20:28
Doesn't the spearation of shape, material and light sources making complex to combine them?
for exemple a plane which emit weak red light and reflect 50% of incoming light?
Aleksey Kladov
@matklad
Oct 02 2017 20:31
Hm, I would say it makes easy to combine them
Because you'll have a SceneObject { shape: Box<Shape>, material: Box<Material>, light: Box<Light> }
and you'll be able to compose any combination of shape, material and light
mnivoliez
@mnivoliez
Oct 02 2017 20:32
I do not understand quite well Box yet
Aleksey Kladov
@matklad
Oct 02 2017 20:36
It allows you to actually use an open-ended set of trait objects
Like, your Sphere and Triangle will probably have different sizeof
So you can't store either of them in a single field, without making an enum
But as Box<Shape> is (hand waving) just a pointer, you can store Box<Shape> which will be either Sphere or Triangle just fine
mnivoliez
@mnivoliez
Oct 02 2017 20:38
I prefer enum, but I get your point
but where did you get primitive?
Aleksey Kladov
@matklad
Oct 02 2017 20:40
Well, it depends on your definition of "primitive".
for shapes, I use Box<Shape>
mnivoliez
@mnivoliez
Oct 02 2017 20:41
but for exemple, in scene/mod.rs, you got scene with primitives, light, material, (I assume reflectance and refractance properties are in there)
Aleksey Kladov
@matklad
Oct 02 2017 20:41
for materials, I actually have only a single material, which is a bunch of float propertirs
so in the primitive material is an index to the table of material prototypes.
mnivoliez
@mnivoliez
Oct 02 2017 20:42
does light and primitives not redondant?
what about a light which is a sphere for exemple?
Aleksey Kladov
@matklad
Oct 02 2017 20:43
Lights are handled completely separately, I don't have things which are both have visible geometry and emit light
mnivoliez
@mnivoliez
Oct 02 2017 20:43
ok
I suppose it solve the dilema
mnivoliez
@mnivoliez
Oct 02 2017 20:47
Ok I'll check that. I think my model is too complex
This message was deleted
Aleksey Kladov
@matklad
Oct 02 2017 20:49
@mnivoliez about enum vs trait, this talks from last year's RustConf offers an interesting perspective: https://www.youtube.com/watch?v=erJdCIti_O8&index=8&list=PLE7tQUdRKcybLShxegjn0xyTTDJeYwEkI :)
mnivoliez
@mnivoliez
Oct 02 2017 20:49
@matklad I'll check that right away
mnivoliez
@mnivoliez
Oct 02 2017 21:07
Very interesting.
he seems to approach the problem by step, enum and then trait
mnivoliez
@mnivoliez
Oct 02 2017 21:16
Well, thanks for the advices and leads. I'm on it since this morning 8:30 am and it's now 23h16, so I think I gonna find some sleep.