These are chat archives for rust-lang/rust

6th
Dec 2016
Paul Betts
@paulcbetts
Dec 06 2016 00:09
(since this is the stdlib I'm 99.9% sure that They Are Correct of course :smile: )
Aleksey Kladov
@matklad
Dec 06 2016 00:21
@paulcbetts I think you may find this chapter of rust book useful: https://doc.rust-lang.org/stable/book/borrow-and-asref.html#borrow
Paul Betts
@paulcbetts
Dec 06 2016 00:48
@matklad Thanks for the tip
Michael Howell
@notriddle
Dec 06 2016 01:05
To summarize: using Borrow allows you to take a HashMap<String, X> and index it with a &str. Or, for that matter, to take a HashMap<Cow<'a, str>, X> and index it with a &str.
Paul Betts
@paulcbetts
Dec 06 2016 04:31
impl<T: Send + Sync + 'static> Lazy<T>
This declaration is saying, "T must have the Send and Sync trait, and have a static lifetime?"
I don't understand that last bit
boats
@withoutboats
Dec 06 2016 04:47
@paulcbetts Having a "static lifetime" means that it contains no references, it fully owns all of its data.
If it were borrowing some of its data, it would have a lifetime bound to however long that data's owner lives, but because it owns everything it can be moved around & live for as long as you want.
xialvjun
@xialvjun
Dec 06 2016 10:36
I'm a windows user. I'm using VisualStudioCode. I want to learn Rust. I'll use VSC extension Rusty Code Native Debug(GDB debug). Then which version(gnu or msvc) rust compiler should I install?
Jarred Nicholls
@jnicholls
Dec 06 2016 12:40
@xialvjun I think either would do, but since you want to use gdb debugger I would go for the gnu compiler. With that said I have not worked with Rust on Windows at all, so take this suggestion lightly.
Jay Looney
@zenware
Dec 06 2016 16:14
Is there a way to access what type a generic is?, like a type_of() function?
Sebastian Blei
@iamsebastian
Dec 06 2016 17:05
Somewhere, I've read it is complicated to do so. What do you need it for?
Jay Looney
@zenware
Dec 06 2016 17:07
@iamsebastian Yeah I've discovered it is complicated, I'm trying to create a Relational Algebra engine, and so an Attribute is a Field name and a Field type, and it would be very useful if I could store the type as an actual type rather than a string saying "Text" or something, although that may be the road I have to take and then just manually handle the supported type.
Aleksey Kladov
@matklad
Dec 06 2016 17:08
Looks like you are looking for TypeId: https://doc.rust-lang.org/std/any/struct.TypeId.html
Jay Looney
@zenware
Dec 06 2016 17:10
The holy choir sings, perhaps it's a downside that I haven't already been coding in rust for a while, I mean I wrote some code when it was first coming out but everything was pre 1.0 for me, and now it's a whole new world. And I've decided to take on a mountain of a project for no good reason
Chakravarthy Raghunandan
@CSRaghunandan
Dec 06 2016 17:24
Will rust language server bring option to query the type of the thing at point? Similar to how haskell does ?
ChristianEspinoza
@chespinoza
Dec 06 2016 18:52
Ukuñp
Lo
Polo
kmlñm0muñ
ChristianEspinoza
@chespinoza
Dec 06 2016 19:47
P
Paul Betts
@paulcbetts
Dec 06 2016 20:55
@withoutboats Thanks for the explanation
boats
@withoutboats
Dec 06 2016 21:37
@paulcbetts no problem. Technically what I said was not complete. There are references with the 'static lifetime. 99% of the static references you'll deal with are string literals, which have the type &'static str. Your type can have &'static strs in it and still be 'static; being 'static basically just means it doesn't have a <'a> in its type.
A static reference is a reference to something in the read-only data part of the binary, rather than to a value you create at runtime.