-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use #[non_exhaustive] instead of manual variant #409
Conversation
Very nice! Can you update |
I'll try to, but I think there are other issues here. I just noticed that locally the tests run fine (I'm not sure if other feature combinations might fail, I can check that). But I think clippy demands these wildcard arms, but |
You can make the match arms themselves conditional. For example instead of #[cfg(feature = "proto-ipv6")]
IpCidr::Ipv6 => None |
ok, I'll check that. README and workflow is updated now 🤞 |
Are we okay bumping the minimum Rust version? I believe @whitequark and https://github.com/m-labs/ have a fork of Rust that they use with this project. |
@crawford this was also mentioned in the issue: #397 (comment) Meanwhile I need help again 😅 Adding the macro_rules! from_socket {
($socket:ty, $variant:ident) => {
impl<'a, 'b> AnySocket<'a, 'b> for $socket {
fn downcast<'c>(ref_: SocketRef<'c, Socket<'a, 'b>>) ->
Option<SocketRef<'c, Self>> {
match SocketRef::into_inner(ref_) {
&mut Socket::$variant(ref mut socket) => Some(SocketRef::new(socket)),
_ => None,
}
}
}
}
} This wildcard matches all other arms that are not given by the macro. Adding all other arms here would complicate this a lot, wouldn't it? |
@whitequark ACKed the MSRV bump #397 (comment) . I'm also for bumping the MSRV. 1.36 is ancient and 1.40 is already a year old. Additionally, this change is not only cosmetic. The extra dummy variants impact code size and struct layout. |
I think using if let Socket::$variant(ref mut socket) = SocketRef::into_inner(ref_) {
Some(...)
} else {
None
} |
Maybe that still triggers some warnings if the |
Better now. I'm still a bit lost here: https://github.com/smoltcp-rs/smoltcp/pull/409/checks?check_run_id=1671886625 It seems that Edit: no, |
Oh, that's very unfortunate. With conditional compilation |
ah this issue seemed like a low hanging fruit 🍒 I'll go to bed now, maybe I've got more ideas tomorrow... |
Actually it turns out that having 2 lifetimes in sockets isn't really needed. I've opened PR #410 to join them in just |
Thank you for the PR @niclashoyer ! |
first issue 🎉
Fixes #397