Ch 5 Structs. Some fairly unique shorthand for initialization with the field init shorthand syntax and .. struct update syntax. Struct tuples as strong typedefs for tuples looks nice. Looks like I have to wait til Ch 10 to see how to have a reference member. #rustlang
-
Show this thread
-
"Methods can take ownership of self" feels weird but I'll try to keep an open mind.
#rustlang1 reply 0 retweets 0 likesShow this thread -
The chapter never explained any rationale for why methods and associated functions (in C++ static member functions) are in a separate impl block apart from the struct definition. It's a mystery.
#rustlang2 replies 0 retweets 0 likesShow this thread -
Also expected to see something about access control ala C++ public/private but no mention of anything like that yet.
#rustlang2 replies 0 retweets 0 likesShow this thread -
Ch 6 Enums in rust look awesome. You can model C-like enums but more interestingly they are sum types that can carry data too. Like a C++ variant but as a language level feature that looks very clean to work with.
#rustlang1 reply 0 retweets 1 likeShow this thread -
It's not clear from this chapter (or I missed it) how enums are actually represented. I suspect they are the size of the largest variant like a C union + extra for the discriminator and that their memory is directly on the stack for a local variable.
#rustlang3 replies 0 retweets 1 likeShow this thread -
If that's the case I wonder if there are any size optimizations for Option<T> where T has a tombstone value.
#rustlang2 replies 0 retweets 0 likesShow this thread -
It's also not clear exactly what happens in a match arm that gets the value out of an enum. Is that value a move/copy/reference or, I hope, just a fancy cast that doesn't change or move anything.
#rustlang2 replies 0 retweets 0 likesShow this thread -
I feel like my comments might come across as a bit overly critical, so let me take a moment to praise the Rust Programming Language book. Thus far the writing is clear and concise, the pacing is great and the examples are solid.
#rustlang1 reply 0 retweets 2 likesShow this thread -
Ch 7 Modules are C++ namespaces on rails, i.e. very specific mod name to file & folder name mappings. I wonder if you can split a single module up into multiple files if the impl gets too big without needed to create submodules.
#rustlang2 replies 0 retweets 0 likesShow this thread
You can’t directly; you can “pub use” to emulate it though
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.