These are chat archives for rust-lang/rust

30th
Dec 2017
Maciej Drożdż
@ekicam2
Dec 30 2017 00:21
Hi all, is there anyoe who would like to help me with set up msvc2017 with rust? :)
i've just started learning rust and I'm using visual code + commend line but it feels terrible having no debug
Steve Klabnik
@steveklabnik
Dec 30 2017 00:22
it should Just Work
i don't use VS, just code
code debugging works with the "native debug" extension
that said i rarely debug things, so other than "give native debug a try" i don't have much advice :)
Steve Klabnik
@steveklabnik
Dec 30 2017 00:25
yup
that said, rust does produce teh pdb files that vs needs to use its debugger
i just have no personal experience with it
Maciej Drożdż
@ekicam2
Dec 30 2017 00:36
is not working as expected, or is not working at all
please help me compile this.
If you don't mind cloning the keys, that will eliminate the borrow i guess
It compiles, but I'm too rokie to tell you if it does what it's supposed to
btw Clippy is not confident with you using a LinkedList for performance sake, you might want to use a Vec or a VecDeque instead https://rust-lang-nursery.github.io/rust-clippy/v0.0.177/index.html#linkedlist
Jeremy Lempereur
@o0Ignition0o
Dec 30 2017 08:49
https://play.rust-lang.org/?gist=5fee1813f1cbf470978e61aa3af1b6fc&version=stable @mmrath here's an other one where you don't clone each key in the list but only the min() you're willing to use, should be less memory intensive :)
Restioson
@Restioson
Dec 30 2017 10:35
My new all time high: https://i.imgur.com/6niu3lA.png
Denis Lisov
@tanriol
Dec 30 2017 10:35
Nice :-)
Restioson
@Restioson
Dec 30 2017 10:37
i was at 38 the other day but seem to have summoned more demons since then
David Harvey-Macaulay
@alteous
Dec 30 2017 18:04
Is there any way of 'grouping' struct members with rustdoc?
pub struct Geometry {
    /// ## Basic geometric properties
    ///
    /// _Mandatory_: Vertex positions.
    pub vertices: Vec<mint::Point3<f32>>,
    /// _Optional_: Vertex normals.
    pub normals: Vec<mint::Vector3<f32>>,
    ///_Optional_: Vertex tangents.
    pub tangents: Vec<mint::Vector4<f32>>,
    ///_Optional_: Vertex texture co-ordinates.
    pub tex_coords: Vec<mint::Point2<f32>>,
    ///_Optional_: Face indices.
    ///
    /// When omitted, the vertex order `[[0, 1, 2], [3, 4, 5], ...]` is
    /// assumed.
    pub faces: Vec<[u32; 3]>,

    /// ## Properties for vertex skinning
    ///
    ///_Optional_: Joint indices, encoded as floats.
    pub joint_indices: Vec<[f32; 4]>,
    ///_Optional_: Joint weights.
    pub joint_weights: Vec<[f32; 4]>,

    /// ## Properties for morph target animation
    ///
    ///_Optional_: Morph target names, one per morph target index.
    pub morph_target_names: VecMap<String>,
    ///_Optional_: Contiguous sets of vertex displacements.
    pub morph_vertices: Vec<mint::Point3<f32>>,
    ///_Optional_: Contiguous sets of normal displacements.
    pub morph_normals: Vec<mint::Vector3<f32>>,
    ///_Optional_: Contiguous sets of tangent displacements.
    pub morph_tangents: Vec<mint::Vector4<f32>>,
}
I'd like the titled parts to be above the field names to 'group' the members in the documentation.
Denis Lisov
@tanriol
Dec 30 2017 18:07
Hmm. What does the "Optional" remark mean?
Are these members independent or not exactly?
David Harvey-Macaulay
@alteous
Dec 30 2017 18:08
It means the user is free to leave the vectors empty, in which case either a default value is assumed or the members are computed on behalf of the user.
Denis Lisov
@tanriol
Dec 30 2017 18:10
May it make sense to group them just by introducing substructures?
David Harvey-Macaulay
@alteous
Dec 30 2017 18:11
Yes... that's a remarkably simple solution.
David Harvey-Macaulay
@alteous
Dec 30 2017 18:32
@tanriol I think that will do. Thanks!
Restioson
@Restioson
Dec 30 2017 19:21
consider Option, too
Steve Klabnik
@steveklabnik
Dec 30 2017 19:22
yeah
it's slightly more boilerplate but semantically more accurate
which is nice
Restioson
@Restioson
Dec 30 2017 19:23
also, consider newtypes/type aliases for some of the things
like joint indices
you can always impl deref/from for them to conv to the array
Denis Lisov
@tanriol
Dec 30 2017 19:25
@alteous Are you passing these arrays directly to some shader?
David Harvey-Macaulay
@alteous
Dec 30 2017 19:28
@tanriol No
Denis Lisov
@tanriol
Dec 30 2017 19:32
The part I don't feel good about is that there's probably some number of hidden requirements on the public fields here, that are mentioned in doc comments in the best case. For example, looking at vertices, normals, tangents and tex_coords vectors I'g guess they have to be equal length, but this is not documented in any way and not enforced in any way. Will the user have to debug mysterious runtime errors if the lengths differ?
David Harvey-Macaulay
@alteous
Dec 30 2017 19:33
Yeah, that's the case. Documentation is a work in progress.
Not sure how that could be enforced.
Denis Lisov
@tanriol
Dec 30 2017 19:40
Obvious but possibly bad for performance: replace a structure of arrays with an array of structures.
More performance-friendly: a Vertices struct contains all them as non-public fields, provides something like impl FromIterator<Vertex> and accessors like fn positions_mut(&mut self) -> &mut [mint::Point3<f32>]
You may also want to take a look at soa-derive
David Harvey-Macaulay
@alteous
Dec 30 2017 19:45
I don't think this would be beneficial.
It's not straightforward to cover every combination of normals/tangents/texture co-ordinates/morph vertices/morph normals/morph tangents etc.
struct Geometry just provides the API with data, nothing more. It's hard to get it wrong.
Restioson
@Restioson
Dec 30 2017 19:48
well array of structs could be simd'ified perhaps
Denis Lisov
@tanriol
Dec 30 2017 19:50
I'd guess it may be hard to get it wrong if you already know the rendering technology and animation inside out, but is this the only case you care about?
David Harvey-Macaulay
@alteous
Dec 30 2017 19:52
Actually, it is. There are helpers/loaders for cases that don't assume any knowledge of the renderer, for example creating simple shapes or loading OBJ/glTF formats.
Restioson
@Restioson
Dec 30 2017 19:52
it's all public
someone could lead it into an invalid state
David Harvey-Macaulay
@alteous
Dec 30 2017 19:53
Thanks for your input but this is getting off-topic. We're discussing this over on https://gitter.im/three-rs/Lobby
Restioson
@Restioson
Dec 30 2017 19:54
IMO it isn't off topic, but ok