These are chat archives for rust-lang/rust

Feb 2019
Feb 20 08:53
is Option::map and Option::and_then the same?
Denis Lisov
Feb 20 08:56
No, and_then flattens the result one level
    assert_eq!(Some(1).map(|x| Some(x)), Some(Some(1u8)));
    assert_eq!(Some(1).and_then(|x| Some(x)), Some(1u8));
Feb 20 08:57
got it. thanks!
Feb 20 09:29
is there a way to cargo run a fn main in The library does not have a
(I only want a main method there for quick prototyping)
Tim Vermeulen
Feb 20 09:34
I suppose you could make a test function called main and then call it using cargo test main
though you could also create a binary that depends on your crate
Feb 20 09:37
that works, wonderful
Sean Perry
Feb 20 21:57
@tsoernes have you seen cargo script?
Brian Knapp
Feb 20 22:03
Moving from locals to using struct fields seems unnecessarily painful. I keep encountering situations where as long as I'm not returning or assigning something onto a field, the compiler can handle all of the binding / re-binding to locals, but once I need explicit types due to having return values and actual struct definitions, I get all kinds of type impedance and warnings about unknown size at compile time.
Félix Fischer
Feb 20 23:17
Hi all. I want to refactor a project that I made in a hurry so that it's easier to read.
I'm currently using Clippy to help me along. Is there anything else you'd recommend I use? Thanks in advance!
(PS: I made it in a hurry! I have no hurries now that it's done, tho)