Twinklebear / tobj

Tiny OBJ Loader in Rust
MIT License
233 stars 47 forks source link

Fix deprecated Error::description #20

Closed alarsyo closed 4 years ago

alarsyo commented 4 years ago

Deprecated since Rust 1.42.

Currently any user that calls error.description() will get a deprecation warning, but this won't prevent their code from compiling: Error has a default implementation for description() (although the text won't be correct now, obviously).

If you want users that relied on this to still get the right text, I can instead add a function

impl LoadError {
    fn msg() -> &str {
        match *self {
            LoadError::OpenFileFailed => "open file failed",
            LoadError::ReadError => "read error",
            LoadError::UnrecognizedCharacter => "unrecognized character",
            LoadError::PositionParseError => "position parse error",
            LoadError::NormalParseError => "normal parse error",
            LoadError::TexcoordParseError => "texcoord parse error",
            LoadError::FaceParseError => "face parse error",
            LoadError::MaterialParseError => "material parse error",
            LoadError::InvalidObjectName => "invalid object name",
            LoadError::GenericFailure => "generic failure",
        }
    }
}

and then use that in both description() and the Display impl.

Twinklebear commented 4 years ago

We can just take this in as a breaking change since the old way is being deprecated anyways. Thanks @alarsyo !