These are chat archives for rust-lang/rust

8th
Oct 2015
panicbit
@panicbit
Oct 08 2015 04:31
@JohanLarsson It seems to appear in one code sample in the book, but thats about it (https://doc.rust-lang.org/book/error-handling.html#handling-errors-with-option-and-result)
Even the reference doesn't mention the full list of derivable traits. Looks like the knowledge about derivable Traits gets passed on by mouth :P
Johan Larsson
@JohanLarsson
Oct 08 2015 06:20
Is the irc channel active?
I'm a collector of chats to lurk in :)
Peter Atashian
@retep998
Oct 08 2015 06:21
yes
IRC is very active
Johan Larsson
@JohanLarsson
Oct 08 2015 06:21
needs a client right?
Peter Atashian
@retep998
Oct 08 2015 06:21
Yes, you need some sort of IRC client
although there are web based IRC clients you can use
Johan Larsson
@JohanLarsson
Oct 08 2015 06:21
ok, chcking i t out
the chat on SO is very nice imo:
been trying to wake it up
it needs a bunch of regs who say something from time to time
Johan Larsson
@JohanLarsson
Oct 08 2015 06:28
what do you use for UIs when coding in Rust?
Peter Atashian
@retep998
Oct 08 2015 07:14
I don't!
Because right now there's no Rust libraries directly wrapping native win32 widgets on Windows, and I dislike GTK on Windows
Johan Larsson
@JohanLarsson
Oct 08 2015 07:23
guess I can write a wrapper function with the cases but nice for tooling to have it like ^
panicbit
@panicbit
Oct 08 2015 07:40
I don't think that's possible, but a simple macro could cut down the redundancy
panicbit
@panicbit
Oct 08 2015 08:12
@JohanLarsson: Take a look at what I've come up with :) http://is.gd/6sU3W0
Johan Larsson
@JohanLarsson
Oct 08 2015 08:13
Nice!
panicbit
@panicbit
Oct 08 2015 08:13
Macros are pretty mad :D
And safe!
Johan Larsson
@JohanLarsson
Oct 08 2015 08:13
Can one write custom attributes?
panicbit
@panicbit
Oct 08 2015 08:14
Like "#[foo]" ?
Or what do you mean exactly?
Johan Larsson
@JohanLarsson
Oct 08 2015 08:14
I still think there is some sense in #[testcase(777, 777)]
panicbit
@panicbit
Oct 08 2015 08:14
You should be able to do that but you'd need to write a compiler plugin
Johan Larsson
@JohanLarsson
Oct 08 2015 08:14
yeah like #[foo]
ok, not for me then :)
panicbit
@panicbit
Oct 08 2015 08:15
Which also implies that you'd need to use nightly rust
I wish I could get rid of the "=>" but ambiguities force me to place SOMETHING there
You could easily replace it by e.g. a semicolon or whatever suits you
This version of the macro might be better, since it forces you to have at least one test case (and thus the function to be run at least once): http://is.gd/H8rl6C
Johan Larsson
@JohanLarsson
Oct 08 2015 08:22
yes
I'm gonna try to write my first macro
looks fun
Johan Larsson
@JohanLarsson
Oct 08 2015 09:44
@panicbit does ^ make any sense?
first macro in any language for me
panicbit
@panicbit
Oct 08 2015 13:03
Looks fine. (Though, for something simple like this, functions are prefered)
This message was deleted
panicbit
@panicbit
Oct 08 2015 13:09
On the other hand, typing out the full return type for such a function can be annoying, so using a macro instead is fine too I guess.
Johan Larsson
@JohanLarsson
Oct 08 2015 13:10
it does not work for static either
time well spent writing it any way
panicbit
@panicbit
Oct 08 2015 13:26
@JohanLarsson Thanks for bringing up that the Rust book was missing a mention of #[derive()]. I added something about it a few hours ago and it got accepted :). You can read it here if you like.
Johan Larsson
@JohanLarsson
Oct 08 2015 13:47
@panicbit looks perfect!
Did not know that deriving only works for a limited set
panicbit
@panicbit
Oct 08 2015 14:53
@JohanLarrson actually that's kind of a lie. You can extend this set with custom derives (like the serde crate does) but that requires nightly rust.
Johan Larsson
@JohanLarsson
Oct 08 2015 20:04
This message was deleted
think the sample code is broken here
oh, nvm, intentional
Johan Larsson
@JohanLarsson
Oct 08 2015 22:36
why is impl better than writing methods oo-style?
Peter Atashian
@retep998
Oct 08 2015 22:52
Because Rust does not have inheritance in the way OOP languages do, adding methods to a type does not affect the layout of the type
Methods can be freely added to or removed from a type without affecting its ABI since it doesn't have a vtable
It also goes well with traits, which can be used to add methods to a type at any time
So it more consistent to always have separate impl blocks
panicbit
@panicbit
Oct 08 2015 22:54
Also you can implement multiple Traits without worrying about diamond-shaped inheritance.
Peter Atashian
@retep998
Oct 08 2015 22:55
Look at me, look back at my hand, I'm on a horse, this C++ inheritance is now diamonds
Johan Larsson
@JohanLarsson
Oct 08 2015 22:59
ok +1 for consistency
I'm an oo-tard, think it is nice to have stuff in the type and be able to collapse the text in the editor.
Inheritance is a smell :)