sile / sloggers

A Rust library which provides frequently used slog loggers and convenient functions
MIT License
37 stars 18 forks source link

Make various items `#[non_exhaustive]` #33

Closed argv-minus-one closed 4 years ago

argv-minus-one commented 4 years ago

Makes various items #[non_exhaustive]. Fixes #32.

Compatibility

⚠ This is a breaking change. In particular, code that constructs a FileLoggerConfig, TerminalLoggerConfig, or KVFilterParameters will need to be changed to use the new method on these types.

⚠ This raises the minimum supported Rust version of this crate to 1.40, which is fairly recent (December 2019).

Changes Made

Items Made Non-Exhaustive

Items Not Made Non-Exhaustive

Non-Exhaustive structs

Note that marking a struct as non-exhaustive changes how to construct it. Instead of using the traditional Struct { .. } syntax, a constructor method must be used.

// This does not work.
let p = KVFilterParameters {
    severity: Severity::Trace,
    .. Default::default()
};

// This works.
let mut p = KVFilterParameters::new();
p.severity = Severity::Trace;

I've marked three structs non-exhaustive: FileLoggerConfig, TerminalLoggerConfig, and KVFilterParameters. I've added a new method to each of them.

Rustdoc generates a short explanation of non-exhaustive structs. I've added a longer explanation to the documentation for KVFilterParameters, since that one seems meant to be constructed by hand, whereas the other two seem meant to be constructed by serde.

codecov-commenter commented 4 years ago

Codecov Report

Merging #33 into master will decrease coverage by 0.57%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
- Coverage   42.24%   41.67%   -0.58%     
==========================================
  Files           8        8              
  Lines         658      667       +9     
==========================================
  Hits          278      278              
- Misses        380      389       +9     
Impacted Files Coverage Δ
src/build.rs 0.00% <ø> (ø)
src/config.rs 0.00% <ø> (ø)
src/error.rs 0.00% <ø> (ø)
src/file.rs 65.36% <0.00%> (-0.52%) :arrow_down:
src/terminal.rs 0.00% <0.00%> (ø)
src/types.rs 21.34% <0.00%> (-0.75%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a51d1fa...052f981. Read the comment docs.