These are chat archives for rust-lang/rust

3rd
Jan 2019
Sergey Nikolaev
@qvantor
Jan 03 07:29
let obj = Object::new();
if (obj == obj) {
        println!("equal")
}
Why i can't even compare two same objects?
Should i always write std::cmp::PartialEq, or there is any solution to fix that?
Tim Robinson
@1tgr
Jan 03 07:32
Does Object have #[derive(PartialEq)] above it?
Sergey Nikolaev
@qvantor
Jan 03 07:33
No, it's adds std::cmp::PartialEq automatically? :)
Tim Robinson
@1tgr
Jan 03 07:34
Yes, PartialEq (and a range of other traits) are implemented automatically only if you ask for them
Sergey Nikolaev
@qvantor
Jan 03 07:35
Oh, make sense. Thank you
It's helps thank you. Can you give me a link on other derive documentation?
Tim Robinson
@1tgr
Jan 03 07:38
https://doc.rust-lang.org/rust-by-example/trait/derive.html, and I’d expect it to be covered in any other Rust tutorial
Sergey Nikolaev
@qvantor
Jan 03 07:39
It's have really usefull one
Ayush Prashar
@ayushprashar
Jan 03 10:01
Hey guys
Can anyone help we in creating a uuid using a string like an email address?
Ayush Prashar
@ayushprashar
Jan 03 10:07
I need to create a unique identifier by using an email id
Tim Robinson
@1tgr
Jan 03 10:15
You want to create a UUID, and you want to get the same UUID given the same email address?
It is based on the hash of a string
Ayush Prashar
@ayushprashar
Jan 03 10:23
Ok
I'll give it a go
thanks Tim
Ayush Prashar
@ayushprashar
Jan 03 11:01
Hey @1tgr
I'm getting a type mismatch error since it expects a slice of unsigned integer
could you give me an example as to how you propose it works
Tim Robinson
@1tgr
Jan 03 11:06
You can turn any string to &[u8] by calling .as_bytes()
Ayush Prashar
@ayushprashar
Jan 03 11:07
ok
Ayush Prashar
@ayushprashar
Jan 03 11:30
thanks a lot tim
Chikirev Sirguy
@cheblin
Jan 03 12:53
I am studying Rust macros. As i understand, macros transformation function receive only restricted part of whole TokenStream . How to get from compiler full TokenStream to iterate through ? Via creating compiler plugin https://doc.rust-lang.org/unstable-book/language-features/plugin.html#lint-plugins ?
Michal 'vorner' Vaner
@vorner
Jan 03 13:08
What do you mean? And, what do you want to do?
Vanquisher Winbringer
@VictoremWinbringer
Jan 03 13:14
Hi, new lib for UDP online game. WIP https://crates.io/crates/victorem
Chikirev Sirguy
@cheblin
Jan 03 13:51
I am creating of the event handler system.
Most projects I'v seen are enforce programmer to mark the Handler functions by attribute macros, so they do transformation and add glue code to call the handler.
I want to simplify a handler creating process. The idea is based on uniqueness handler function signature for the specific event.
I need to get full compiler AST , search and group functions with similar specific signature and generate code to call them sequentially.
wegry
@wegry
Jan 03 14:28
If I have two folders (a and b) with a mod.rs in them, and both depend on a dep.rs, is there a way to put dep.rs at the same folder level?
Michal 'vorner' Vaner
@vorner
Jan 03 14:40
@cheblin I'm not sure, but you might be able to put the attribute on the whole module? Maybe?
But this searching and such… if any crate wanted to do that to my code, I'd probably avoid it. I like the fact that Rust does things only if told to and all such things are visible in the code.