You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason in the files i'm trying to use the from_u8 function, i have to use crate::num::FromPrimitive and depend on num = "0.2.0" in Cargo.toml`
Without the num crate or use crate::num::FromPrimitive I get this error:
error[E0599]: no variant or associated item named `from_u8` found for type `igmp::types::IgmpType` in the current scope
--> src/igmp/header.rs:13:19
|
13 | IgmpType::from_u8(self.itype)
| ^^^^^^^ variant or associated item not found in `igmp::types::IgmpType`
|
::: src/igmp/types.rs:5:1
|
5 | pub enum IgmpType {
| ----------------- variant or associated item `from_u8` not found here
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
`use crate::num::FromPrimitive;`
error: aborting due to previous error
The text was updated successfully, but these errors were encountered:
You do need to import the trait into scope where you want to call its methods, but it should be fine to just use num_traits::FromPrimitive. I don't know why the compiler would suggest using the re-export from num instead -- maybe that's already added elsewhere in your dependency tree, and it's getting confused about what path should be the canonical suggestion.
I'm trying to use num_derive, but the way I got it working doesn't align to the documentation.
Enum definition:
https://github.com/ruckc/mcr/blob/num_derive/src/igmp/types.rs#L4
Seemingly required use:
https://github.com/ruckc/mcr/blob/num_derive/src/igmp/header.rs#L3
For some reason in the files i'm trying to use the
from_u8
function, i have touse crate::num::FromPrimitive
and depend onnum = "0.2.0" in
Cargo.toml`Without the
num
crate oruse crate::num::FromPrimitive
I get this error:The text was updated successfully, but these errors were encountered: