BurntSushi / byteorder

Rust library for reading/writing numbers in big-endian and little-endian.
The Unlicense
984 stars 144 forks source link

Rust is failing to find type definitions or enumerations #178

Closed ethindp closed 3 years ago

ethindp commented 3 years ago

I'm using this code:

use byteorder::*;

#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, FromBytes, AsBytes)]
pub struct IdentifyNamespaceResponse {
    /// Namespace size
    pub nsez: U64<LE>,
    /// Namespace capabilities
    pub ncap: U64<LE>,
    /// Namespace utilization
    pub nuse: U64<LE>,
//...

The problem is that Rust is claiming that it can't find LE and BE. I've looked at the git code and the typedefs exist and are public. I'm using no_std but the typedefs don't appear to be gated either. So it tells me to try and import it (because for some reason the glob import doesn't do that in this instance) and it now says "unresolved imports byteorder::LE, byteorder::BE". So I'm really, really confused here. Am I missing something obvious?

ethindp commented 3 years ago

Okay... So I did something really, really stupid. No wonder. I'm using the zerocopy crate and it has a module called byteorder, so I'm confusing the compiler. Wow, I can't believe I missed that! :-)

BurntSushi commented 3 years ago

@ethindp No worries. Thank you for sharing your solution. Also, in the future, when submitting bug reports, it's a good idea to provide a complete reproduction of the problem. That is, I should be able to copy your code snippet as is and that should reproduce the problem.