What would probably be nice here is a custom derive that generates is_foo methods
-
-
Replying to @ManishEarth @yoshuawuyts
But I find this imports thing a symptom of a larger issue: we should just be able to match on named variants when the type is known, perhaps using some syntax like `*::Foo` or straight up `::Foo`
1 reply 0 retweets 1 like -
Replying to @ManishEarth
Do you mean something like: if gen_pasta()::Tagliatelle {println!("serving tagliatelle");}
1 reply 0 retweets 0 likes -
-
Replying to @ManishEarth @yoshuawuyts
yeah, that's nicer IMHO, less boilerplate, and ideally as forward-compatible with `#[non_exhaustive]`. Swift has something like that, I think their syntax would be something like `if let .Penne = get_pasta() { … }` in Rust
1 reply 0 retweets 1 like -
Replying to @killercup @yoshuawuyts
In rust 2018 ::Foo isn't necessary anymore so we can repurpose the syntax without ambiguity. I think
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @yoshuawuyts
But it's the thing you use for absolute paths in 2015. The exact opposite of local path inference
1 reply 0 retweets 0 likes -
Replying to @killercup @yoshuawuyts
Right, this feature would be 2018 only if done this way. Additional goodie to encourage transition.
1 reply 0 retweets 0 likes -
if let Foo = ... is also doable with fallback
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @yoshuawuyts
My point was more about the confusion not the "2018 only" aspect :) while I quite like the one without any prefix, it's very much against the usually quite explicit nature of Rust as a language… (if we do this, I'd also ask for this when writing struct instances, e.g.)
1 reply 0 retweets 2 likes
What would an example of this be for struct instances?
-
-
-
- 1 more reply
New conversation -
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.