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

Fix deprecated Error::description #20

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

alarsyo
Copy link
Contributor

@alarsyo alarsyo commented Mar 26, 2020

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
Copy link
Owner

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

@Twinklebear Twinklebear merged commit 78b9eb0 into Twinklebear:master Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants