fix: resolve compilation errors for link module#212
Open
demurgos wants to merge 1 commit intohyperium:masterfrom
Open
fix: resolve compilation errors for link module#212demurgos wants to merge 1 commit intohyperium:masterfrom
link module#212demurgos wants to merge 1 commit intohyperium:masterfrom
Conversation
The `link` module is currently located in the `./src/disabled` directory. The content of this directory is not mounted as a module in the crate source, so it is not compiled by default. Over time, the code structure, language features and dependencies changed, but the `link` module was not kept up to date and now the module no longer compiles.
This commit fixes compilation errors for the existing `link` module. This was achieved by temporarily adding `mod disabled { mod link; }` in the root module and addressing all the errors reported by the compiler. While this commit is part of an overall effort of adding support for `Link` headers, this specific commit restricts its code changes purely to compilation errors. In particular, it does not introduce any change in behavior, and the module remains disabled.
Here is the detailed list of changes:
- The `try!` macro was replaced with the try operator `?` because `try` is a reserved keyword since Rust 2018. An alternative would have been to use `r#try`, however `?` is more idiomatic in Rust 2018. There are no compat concerns, all Rust versions supported by `headers` support the edition 2018.
- Update `Header` impl for `Link` to use the latest function signature.
- Rephrase comment in `Header::decode` impl for `Link` (fix typo, improve clarity)
- Use standard `Result` type, the code was previously relying on a local type alias for `Result<T, crate::Error>`.
- Reformat with Rustfmt
- Replace `::Error::Header` with `Error::invalid()`
- Remove useless semicolon in `test_link_fmt_delimited`
- Replace `Header::parse_header` with `crate::common::test_decode`
- Add module level documentation
- Update doc tests for `Link`
Note: to compile, the code requires adding the dependency `language_tags` version `0.3`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
linkmodule is currently located in the./src/disableddirectory. The content of this directory is not mounted as a module in the crate source, so it is not compiled by default. Over time, the code structure, language features and dependencies changed, but thelinkmodule was not kept up to date and now the module no longer compiles.This commit fixes compilation errors for the existing
linkmodule. This was achieved by temporarily addingmod disabled { mod link; }in the root module and addressing all the errors reported by the compiler. While this commit is part of an overall effort of adding support forLinkheaders, this specific commit restricts its code changes purely to compilation errors. In particular, it does not introduce any change in behavior, and the module remains disabled.Here is the detailed list of changes:
try!macro was replaced with the try operator?becausetryis a reserved keyword since Rust 2018. An alternative would have been to user#try, however?is more idiomatic in Rust 2018. There are no compat concerns, all Rust versions supported byheaderssupport the edition 2018.Headerimpl forLinkto use the latest function signature.Header::decodeimpl forLink(fix typo, improve clarity)Resulttype, the code was previously relying on a local type alias forResult<T, crate::Error>.::Error::HeaderwithError::invalid()test_link_fmt_delimitedHeader::parse_headerwithcrate::common::test_decodeLinkNote: to compile, the code requires adding the dependency
language_tagsversion0.3.This commit is a step towards #211.