Skip to content

Commit

Permalink
Better linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Oct 30, 2023
1 parent 91d93cb commit 3889422
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
v0.2.0 (in development)
-----------------------

v0.1.0 (2023-10-30)
-------------------
Initial release
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cfgfifo"
version = "0.1.0"
version = "0.2.0-dev"
edition = "2021"
rust-version = "1.67"
description = "(De)serialize common configuration file formats based on file extension"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Minimum Supported Rust Version](https://img.shields.io/badge/MSRV-1.67-orange)](https://www.rust-lang.org)
[![MIT License](https://img.shields.io/github/license/jwodder/cfgfifo.svg)](https://opensource.org/licenses/MIT)

[GitHub](https://github.com/jwodder/cfgfifo) | [crates.io](https://crates.io/crates/cfgfifo) | [Documentation](https://docs.rs/cfgfifo) | [Issues](https://github.com/jwodder/cfgfifo/issues)
[GitHub](https://github.com/jwodder/cfgfifo) | [crates.io](https://crates.io/crates/cfgfifo) | [Documentation](https://docs.rs/cfgfifo) | [Issues](https://github.com/jwodder/cfgfifo/issues) | [Changelog](https://github.com/jwodder/cfgfifo/blob/master/CHANGELOG.md)

`cfgfifo` is a Rust library for serializing & deserializing various common
configuration file formats ([JSON][], [JSON5][], [RON][], [TOML][], and
Expand Down
19 changes: 11 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
//! ```
use serde::{de::DeserializeOwned, Serialize};
#[allow(unused)]
#[allow(unused_imports)]
use serde_path_to_error::{deserialize as depath, serialize as serpath, Error as PathError};
use std::fs::File;
use std::io;
Expand Down Expand Up @@ -307,7 +307,7 @@ impl Format {
/// # Errors
///
/// Returns an error if the underlying serializer returns an error.
#[allow(unused)]
#[allow(unused_variables)]
pub fn dump_to_string<T: Serialize>(&self, value: &T) -> Result<String, SerializeError> {
match self {
#[cfg(feature = "json")]
Expand All @@ -319,8 +319,7 @@ impl Format {
}
#[cfg(feature = "json5")]
Format::Json5 => {
/// json5::to_string() just serializes as JSON, but
/// non-prettily.
// json5::to_string() just serializes as JSON, but non-prettily
let mut buffer = Vec::new();
let mut ser = serde_json::Serializer::pretty(&mut buffer);
serpath(value, &mut ser)?;
Expand All @@ -347,6 +346,7 @@ impl Format {
self.dump_to_writer(&mut buffer, value)?;
Ok(String::from_utf8(buffer).expect("serialized YAML should be valid UTF-8"))
}
#[allow(unreachable_patterns)]
_ => unreachable!(),
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl Format {
/// # Errors
///
/// Returns an error if the underlying deserializer returns an error.
#[allow(unused)]
#[allow(unused_variables)]
pub fn load_from_str<T: DeserializeOwned>(&self, s: &str) -> Result<T, DeserializeError> {
match self {
#[cfg(feature = "json")]
Expand Down Expand Up @@ -429,6 +429,7 @@ impl Format {
let de = serde_yaml::Deserializer::from_str(s);
depath(de).map_err(Into::into)
}
#[allow(unreachable_patterns)]
_ => unreachable!(),
}
}
Expand All @@ -443,7 +444,7 @@ impl Format {
///
/// Returns an error if an I/O error occurs or if the underlying serializer
/// returns an error.
#[allow(unused)]
#[allow(unused_mut, unused_variables)]
pub fn dump_to_writer<W: io::Write, T: Serialize>(
&self,
mut writer: W,
Expand Down Expand Up @@ -485,6 +486,7 @@ impl Format {
let mut ser = serde_yaml::Serializer::new(writer);
serpath(value, &mut ser).map_err(Into::into)
}
#[allow(unreachable_patterns)]
_ => unreachable!(),
}
}
Expand All @@ -495,10 +497,10 @@ impl Format {
///
/// Returns an error if an I/O error occurs or if the underlying
/// deserializer returns an error.
#[allow(unused)]
#[allow(unused_variables)]
pub fn load_from_reader<R: io::Read, T: DeserializeOwned>(
&self,
mut reader: R,
reader: R,
) -> Result<T, DeserializeError> {
match self {
#[cfg(feature = "json")]
Expand Down Expand Up @@ -528,6 +530,7 @@ impl Format {
let de = serde_yaml::Deserializer::from_reader(reader);
depath(de).map_err(Into::into)
}
#[allow(unreachable_patterns)]
_ => unreachable!(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct RonConfig {
}

impl RonConfig {
#[allow(unused)]
#[allow(dead_code)]
fn get() -> RonConfig {
RonConfig {
primitives: Primitives::get(),
Expand All @@ -152,7 +152,7 @@ struct RonEnums {
}

impl RonEnums {
#[allow(unused)]
#[allow(dead_code)]
fn get() -> RonEnums {
RonEnums {
color: Color::Green,
Expand Down

0 comments on commit 3889422

Please sign in to comment.