Skip to content
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

Documentation inaccurate? #27

Open
ruckc opened this issue Aug 4, 2019 · 1 comment
Open

Documentation inaccurate? #27

ruckc opened this issue Aug 4, 2019 · 1 comment
Labels

Comments

@ruckc
Copy link

ruckc commented Aug 4, 2019

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 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
@cuviper
Copy link
Member

cuviper commented Aug 5, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants