diff options
-rw-r--r-- | .clippy.toml | 1 | ||||
-rw-r--r-- | .github/workflows/msrv.yml | 13 | ||||
-rw-r--r-- | src/de.rs | 6 | ||||
-rw-r--r-- | src/file/format/mod.rs | 1 | ||||
-rw-r--r-- | src/lib.rs | 29 | ||||
-rw-r--r-- | src/path/parser.rs | 2 | ||||
-rw-r--r-- | src/ser.rs | 15 | ||||
-rw-r--r-- | src/source.rs | 4 | ||||
-rw-r--r-- | src/value.rs | 30 |
9 files changed, 37 insertions, 64 deletions
diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 0000000..eb66960 --- /dev/null +++ b/.clippy.toml @@ -0,0 +1 @@ +msrv = "1.46" diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index 95f1e0a..68562ba 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -22,6 +22,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + minimal: true override: true - name: Run cargo check @@ -56,6 +57,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + minimal: true override: true - name: Run cargo test @@ -98,10 +100,9 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + minimal: true override: true - - - name: Install rustfmt - run: rustup component add rustfmt + components: rustfmt - name: Run cargo fmt uses: actions-rs/cargo@v1 @@ -127,10 +128,9 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + minimal: true override: true - - - name: Install clippy - run: rustup component add clippy + components: clippy - name: Run cargo clippy uses: actions-rs/cargo@v1 @@ -156,6 +156,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + minimal: true override: true - name: Run cargo check @@ -138,7 +138,7 @@ impl<'de> de::Deserializer<'de> for Value { }) } - forward_to_deserialize_any! { + serde::forward_to_deserialize_any! { char seq bytes byte_buf map struct unit identifier ignored_any unit_struct tuple_struct tuple @@ -155,7 +155,7 @@ impl<'de, 'a> de::Deserializer<'de> for StrDeserializer<'a> { visitor.visit_str(self.0) } - forward_to_deserialize_any! { + serde::forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq bytes byte_buf map struct unit enum newtype_struct identifier ignored_any unit_struct tuple_struct tuple option @@ -460,7 +460,7 @@ impl<'de> de::Deserializer<'de> for Config { }) } - forward_to_deserialize_any! { + serde::forward_to_deserialize_any! { char seq bytes byte_buf map struct unit newtype_struct identifier ignored_any unit_struct tuple_struct tuple diff --git a/src/file/format/mod.rs b/src/file/format/mod.rs index d8817f2..3c18e3c 100644 --- a/src/file/format/mod.rs +++ b/src/file/format/mod.rs @@ -2,6 +2,7 @@ // BUG: ? For some reason this doesn't do anything if I try and function scope this #![allow(unused_mut)] +use lazy_static::lazy_static; use std::collections::HashMap; use std::error::Error; @@ -21,35 +21,6 @@ #![allow(unknown_lints)] // #![warn(missing_docs)] -#[macro_use] -extern crate serde; - -#[cfg(test)] -extern crate serde_derive; - -extern crate nom; - -#[macro_use] -extern crate lazy_static; - -#[cfg(feature = "toml")] -extern crate toml; - -#[cfg(feature = "json")] -extern crate serde_json; - -#[cfg(feature = "yaml")] -extern crate yaml_rust; - -#[cfg(feature = "ini")] -extern crate ini; - -#[cfg(feature = "ron")] -extern crate ron; - -#[cfg(feature = "json5")] -extern crate json5_rs; - pub mod builder; mod config; mod de; diff --git a/src/path/parser.rs b/src/path/parser.rs index 1867657..8378121 100644 --- a/src/path/parser.rs +++ b/src/path/parser.rs @@ -20,7 +20,7 @@ fn raw_ident(i: &str) -> IResult<&str, String> { 0123456789 \ _-", ), - |s: &str| s.to_string(), + ToString::to_string, )(i) } @@ -98,15 +98,15 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer { } fn serialize_i8(self, v: i8) -> Result<Self::Ok> { - self.serialize_i64(v as i64) + self.serialize_i64(v.into()) } fn serialize_i16(self, v: i16) -> Result<Self::Ok> { - self.serialize_i64(v as i64) + self.serialize_i64(v.into()) } fn serialize_i32(self, v: i32) -> Result<Self::Ok> { - self.serialize_i64(v as i64) + self.serialize_i64(v.into()) } fn serialize_i64(self, v: i64) -> Result<Self::Ok> { @@ -114,15 +114,15 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer { } fn serialize_u8(self, v: u8) -> Result<Self::Ok> { - self.serialize_u64(v as u64) + self.serialize_u64(v.into()) } fn serialize_u16(self, v: u16) -> Result<Self::Ok> { - self.serialize_u64(v as u64) + self.serialize_u64(v.into()) } fn serialize_u32(self, v: u32) -> Result<Self::Ok> { - self.serialize_u64(v as u64) + self.serialize_u64(v.into()) } fn serialize_u64(self, v: u64) -> Result<Self::Ok> { @@ -138,7 +138,7 @@ impl<'a> ser::Serializer for &'a mut ConfigSerializer { } fn serialize_f32(self, v: f32) -> Result<Self::Ok> { - self.serialize_f64(v as f64) + self.serialize_f64(v.into()) } fn serialize_f64(self, v: f64) -> Result<Self::Ok> { @@ -698,6 +698,7 @@ impl ser::SerializeStructVariant for StringKeySerializer { #[cfg(test)] mod test { use super::*; + use serde::{Deserialize, Serialize}; #[test] fn test_struct() { diff --git a/src/source.rs b/src/source.rs index 0faf6d1..69cef56 100644 --- a/src/source.rs +++ b/src/source.rs @@ -123,9 +123,7 @@ impl Source for [Box<dyn Source + Send + Sync>] { impl<T> Source for Vec<T> where - T: Source + Sync + Send, - T: Clone, - T: 'static, + T: Source + Sync + Send + Clone + 'static, { fn clone_into_box(&self) -> Box<dyn Source + Send + Sync> { Box::new((*self).clone()) diff --git a/src/value.rs b/src/value.rs index c88d8a9..2a274cb 100644 --- a/src/value.rs +++ b/src/value.rs @@ -60,19 +60,19 @@ impl<'a> From<&'a str> for ValueKind { impl From<i8> for ValueKind { fn from(value: i8) -> Self { - ValueKind::I64(value as i64) + ValueKind::I64(value.into()) } } impl From<i16> for ValueKind { fn from(value: i16) -> Self { - ValueKind::I64(value as i64) + ValueKind::I64(value.into()) } } impl From<i32> for ValueKind { fn from(value: i32) -> Self { - ValueKind::I64(value as i64) + ValueKind::I64(value.into()) } } @@ -90,19 +90,19 @@ impl From<i128> for ValueKind { impl From<u8> for ValueKind { fn from(value: u8) -> Self { - ValueKind::U64(value as u64) + ValueKind::U64(value.into()) } } impl From<u16> for ValueKind { fn from(value: u16) -> Self { - ValueKind::U64(value as u64) + ValueKind::U64(value.into()) } } impl From<u32> for ValueKind { fn from(value: u32) -> Self { - ValueKind::U64(value as u64) + ValueKind::U64(value.into()) } } @@ -322,9 +322,9 @@ impl Value { /// Returns `self` into an i128, if possible. pub fn into_int128(self) -> Result<i128> { match self.kind { - ValueKind::I64(value) => Ok(value as i128), + ValueKind::I64(value) => Ok(value.into()), ValueKind::I128(value) => Ok(value), - ValueKind::U64(value) => Ok(value as i128), + ValueKind::U64(value) => Ok(value.into()), ValueKind::U128(value) => Err(ConfigError::invalid_type( self.origin, Unexpected::U128(value), @@ -433,7 +433,7 @@ impl Value { /// Returns `self` into an u128, if possible. pub fn into_uint128(self) -> Result<u128> { match self.kind { - ValueKind::U64(value) => Ok(value as u128), + ValueKind::U64(value) => Ok(value.into()), ValueKind::U128(value) => Ok(value), ValueKind::I64(value) => Err(ConfigError::invalid_type( self.origin, @@ -698,17 +698,17 @@ impl<'de> Deserialize<'de> for Value { #[inline] fn visit_i8<E>(self, value: i8) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] fn visit_i16<E>(self, value: i16) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] fn visit_i32<E>(self, value: i32) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] @@ -723,17 +723,17 @@ impl<'de> Deserialize<'de> for Value { #[inline] fn visit_u8<E>(self, value: u8) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] fn visit_u16<E>(self, value: u16) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] fn visit_u32<E>(self, value: u32) -> ::std::result::Result<Value, E> { - Ok((value as i64).into()) + Ok((i64::from(value)).into()) } #[inline] |