diff --git a/Cargo.toml b/Cargo.toml index 9ca9671..f231a90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace] members = ["crates/*"] -resolver = "2" +resolver = "3" [workspace.package] repository = "https://github.com/assert-rs/predicates-rs" license = "MIT OR Apache-2.0" -edition = "2021" -rust-version = "1.74" # MSRV +edition = "2024" +rust-version = "1.85" # MSRV include = [ "build.rs", "src/**/*", diff --git a/src/boolean.rs b/src/boolean.rs index a730f14..48a90d0 100644 --- a/src/boolean.rs +++ b/src/boolean.rs @@ -11,8 +11,8 @@ use std::fmt; use std::marker::PhantomData; -use crate::reflection; use crate::Predicate; +use crate::reflection; /// Predicate that combines two `Predicate`s, returning the AND of the results. /// @@ -123,66 +123,82 @@ mod test_and { #[test] fn find_case_true() { - assert!(predicate::always() - .and(predicate::always()) - .find_case(true, &5) - .is_some()); + assert!( + predicate::always() + .and(predicate::always()) + .find_case(true, &5) + .is_some() + ); } #[test] fn find_case_true_left_fail() { - assert!(predicate::never() - .and(predicate::always()) - .find_case(true, &5) - .is_none()); + assert!( + predicate::never() + .and(predicate::always()) + .find_case(true, &5) + .is_none() + ); } #[test] fn find_case_true_right_fail() { - assert!(predicate::always() - .and(predicate::never()) - .find_case(true, &5) - .is_none()); + assert!( + predicate::always() + .and(predicate::never()) + .find_case(true, &5) + .is_none() + ); } #[test] fn find_case_true_fails() { - assert!(predicate::never() - .and(predicate::never()) - .find_case(true, &5) - .is_none()); + assert!( + predicate::never() + .and(predicate::never()) + .find_case(true, &5) + .is_none() + ); } #[test] fn find_case_false() { - assert!(predicate::never() - .and(predicate::never()) - .find_case(false, &5) - .is_some()); + assert!( + predicate::never() + .and(predicate::never()) + .find_case(false, &5) + .is_some() + ); } #[test] fn find_case_false_fails() { - assert!(predicate::always() - .and(predicate::always()) - .find_case(false, &5) - .is_none()); + assert!( + predicate::always() + .and(predicate::always()) + .find_case(false, &5) + .is_none() + ); } #[test] fn find_case_false_left_fail() { - assert!(predicate::never() - .and(predicate::always()) - .find_case(false, &5) - .is_some()); + assert!( + predicate::never() + .and(predicate::always()) + .find_case(false, &5) + .is_some() + ); } #[test] fn find_case_false_right_fail() { - assert!(predicate::always() - .and(predicate::never()) - .find_case(false, &5) - .is_some()); + assert!( + predicate::always() + .and(predicate::never()) + .find_case(false, &5) + .is_some() + ); } } @@ -295,66 +311,82 @@ mod test_or { #[test] fn find_case_true() { - assert!(predicate::always() - .or(predicate::always()) - .find_case(true, &5) - .is_some()); + assert!( + predicate::always() + .or(predicate::always()) + .find_case(true, &5) + .is_some() + ); } #[test] fn find_case_true_left_fail() { - assert!(predicate::never() - .or(predicate::always()) - .find_case(true, &5) - .is_some()); + assert!( + predicate::never() + .or(predicate::always()) + .find_case(true, &5) + .is_some() + ); } #[test] fn find_case_true_right_fail() { - assert!(predicate::always() - .or(predicate::never()) - .find_case(true, &5) - .is_some()); + assert!( + predicate::always() + .or(predicate::never()) + .find_case(true, &5) + .is_some() + ); } #[test] fn find_case_true_fails() { - assert!(predicate::never() - .or(predicate::never()) - .find_case(true, &5) - .is_none()); + assert!( + predicate::never() + .or(predicate::never()) + .find_case(true, &5) + .is_none() + ); } #[test] fn find_case_false() { - assert!(predicate::never() - .or(predicate::never()) - .find_case(false, &5) - .is_some()); + assert!( + predicate::never() + .or(predicate::never()) + .find_case(false, &5) + .is_some() + ); } #[test] fn find_case_false_fails() { - assert!(predicate::always() - .or(predicate::always()) - .find_case(false, &5) - .is_none()); + assert!( + predicate::always() + .or(predicate::always()) + .find_case(false, &5) + .is_none() + ); } #[test] fn find_case_false_left_fail() { - assert!(predicate::never() - .or(predicate::always()) - .find_case(false, &5) - .is_none()); + assert!( + predicate::never() + .or(predicate::always()) + .find_case(false, &5) + .is_none() + ); } #[test] fn find_case_false_right_fail() { - assert!(predicate::always() - .or(predicate::never()) - .find_case(false, &5) - .is_none()); + assert!( + predicate::always() + .or(predicate::never()) + .find_case(false, &5) + .is_none() + ); } } diff --git a/src/boxed.rs b/src/boxed.rs index 2e473d9..138688c 100644 --- a/src/boxed.rs +++ b/src/boxed.rs @@ -11,8 +11,8 @@ use std::fmt; -use crate::reflection; use crate::Predicate; +use crate::reflection; /// `Predicate` that wraps another `Predicate` as a trait object, allowing /// sized storage of predicate types. diff --git a/src/constant.rs b/src/constant.rs index 79cbb86..84dba5a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -10,9 +10,9 @@ use std::fmt; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// Predicate that always returns a constant (boolean) result. /// diff --git a/src/float/close.rs b/src/float/close.rs index b216ac7..8fab31f 100644 --- a/src/float/close.rs +++ b/src/float/close.rs @@ -11,8 +11,8 @@ use std::fmt; use float_cmp::ApproxEq; use float_cmp::Ulps; -use crate::reflection; use crate::Predicate; +use crate::reflection; /// Predicate that ensures two numbers are "close" enough, understanding that rounding errors /// occur. diff --git a/src/float/mod.rs b/src/float/mod.rs index 76c3377..50ac13e 100644 --- a/src/float/mod.rs +++ b/src/float/mod.rs @@ -13,4 +13,4 @@ #[cfg(feature = "float-cmp")] mod close; #[cfg(feature = "float-cmp")] -pub use self::close::{is_close, IsClosePredicate}; +pub use self::close::{IsClosePredicate, is_close}; diff --git a/src/function.rs b/src/function.rs index e6eecaa..aeb0cac 100644 --- a/src/function.rs +++ b/src/function.rs @@ -11,9 +11,9 @@ use std::fmt; use std::marker::PhantomData; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// Predicate that wraps a function over a reference that returns a `bool`. /// This type is returned by the `predicate::function` function. diff --git a/src/iter.rs b/src/iter.rs index 03b69b2..58ef07d 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -13,9 +13,9 @@ use std::fmt; use std::hash::Hash; use std::iter::FromIterator; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// Predicate that returns `true` if `variable` is a member of the pre-defined /// set, otherwise returns `false`. diff --git a/src/name.rs b/src/name.rs index d204145..2df44ab 100644 --- a/src/name.rs +++ b/src/name.rs @@ -11,8 +11,8 @@ use std::fmt; use std::marker::PhantomData; -use crate::reflection; use crate::Predicate; +use crate::reflection; /// Augment an existing predicate with a name. /// diff --git a/src/ord.rs b/src/ord.rs index 4c2305c..27269b8 100644 --- a/src/ord.rs +++ b/src/ord.rs @@ -10,9 +10,9 @@ use std::fmt; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum EqOps { diff --git a/src/path/existence.rs b/src/path/existence.rs index 343a9c1..cf35293 100644 --- a/src/path/existence.rs +++ b/src/path/existence.rs @@ -9,9 +9,9 @@ use std::fmt; use std::path; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// Predicate that checks if a file is present /// diff --git a/src/path/fc.rs b/src/path/fc.rs index bcb92c7..03f0452 100644 --- a/src/path/fc.rs +++ b/src/path/fc.rs @@ -11,8 +11,8 @@ use std::fs; use std::io::{self, Read}; use std::path; -use crate::reflection; use crate::Predicate; +use crate::reflection; fn read_file(path: &path::Path) -> io::Result> { let mut buffer = Vec::new(); diff --git a/src/path/fs.rs b/src/path/fs.rs index 22291ea..e3da34b 100644 --- a/src/path/fs.rs +++ b/src/path/fs.rs @@ -11,9 +11,9 @@ use std::fs; use std::io::{self, Read}; use std::path; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; fn read_file(path: &path::Path) -> io::Result> { let mut buffer = Vec::new(); diff --git a/src/path/ft.rs b/src/path/ft.rs index eec09f7..f357ac4 100644 --- a/src/path/ft.rs +++ b/src/path/ft.rs @@ -11,8 +11,8 @@ use std::fs; use std::io; use std::path; -use crate::reflection; use crate::Predicate; +use crate::reflection; #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum FileType { diff --git a/src/path/mod.rs b/src/path/mod.rs index 8c0ed9a..0821dd3 100644 --- a/src/path/mod.rs +++ b/src/path/mod.rs @@ -11,10 +11,10 @@ //! This module contains predicates specific to the file system. mod existence; -pub use self::existence::{exists, missing, ExistencePredicate}; +pub use self::existence::{ExistencePredicate, exists, missing}; mod ft; -pub use self::ft::{is_dir, is_file, is_symlink, FileTypePredicate}; +pub use self::ft::{FileTypePredicate, is_dir, is_file, is_symlink}; mod fc; pub use self::fc::{FileContentPredicate, PredicateFileContentExt}; mod fs; -pub use self::fs::{eq_file, BinaryFilePredicate, StrFilePredicate}; +pub use self::fs::{BinaryFilePredicate, StrFilePredicate, eq_file}; diff --git a/src/prelude.rs b/src/prelude.rs index 8cfd447..ebd58b3 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -8,12 +8,12 @@ //! Module that contains the essentials for working with predicates. +pub use crate::Predicate; pub use crate::boolean::PredicateBooleanExt; pub use crate::boxed::PredicateBoxExt; pub use crate::name::PredicateNameExt; pub use crate::path::PredicateFileContentExt; pub use crate::str::PredicateStrExt; -pub use crate::Predicate; /// Predicate factories pub mod predicate { diff --git a/src/str/adapters.rs b/src/str/adapters.rs index 96856bc..7dc197c 100644 --- a/src/str/adapters.rs +++ b/src/str/adapters.rs @@ -10,10 +10,10 @@ use std::ffi; use std::fmt; use std::str; +use crate::Predicate; use crate::reflection; #[cfg(feature = "normalize-line-endings")] use crate::str::normalize::NormalizedPredicate; -use crate::Predicate; /// Predicate adapter that trims the variable being tested. /// diff --git a/src/str/basics.rs b/src/str/basics.rs index 90b2ed8..1b949d7 100644 --- a/src/str/basics.rs +++ b/src/str/basics.rs @@ -8,9 +8,9 @@ use std::fmt; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// Predicate that checks for empty strings. /// diff --git a/src/str/difference.rs b/src/str/difference.rs index 0a362dc..fec3cac 100644 --- a/src/str/difference.rs +++ b/src/str/difference.rs @@ -9,8 +9,8 @@ use std::borrow; use std::fmt; -use crate::reflection; use crate::Predicate; +use crate::reflection; /// Predicate that diffs two strings. /// diff --git a/src/str/mod.rs b/src/str/mod.rs index 254656c..8666728 100644 --- a/src/str/mod.rs +++ b/src/str/mod.rs @@ -18,7 +18,7 @@ pub use self::adapters::*; #[cfg(feature = "diff")] mod difference; #[cfg(feature = "diff")] -pub use self::difference::{diff, DifferencePredicate}; +pub use self::difference::{DifferencePredicate, diff}; #[cfg(feature = "normalize-line-endings")] mod normalize; #[cfg(feature = "normalize-line-endings")] @@ -27,4 +27,4 @@ pub use self::normalize::NormalizedPredicate; #[cfg(feature = "regex")] mod regex; #[cfg(feature = "regex")] -pub use self::regex::{is_match, RegexError, RegexMatchesPredicate, RegexPredicate}; +pub use self::regex::{RegexError, RegexMatchesPredicate, RegexPredicate, is_match}; diff --git a/src/str/normalize.rs b/src/str/normalize.rs index 6a65733..ea73e1d 100644 --- a/src/str/normalize.rs +++ b/src/str/normalize.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use crate::reflection; use crate::Predicate; +use crate::reflection; use std::fmt; use normalize_line_endings::normalized; diff --git a/src/str/regex.rs b/src/str/regex.rs index abb46f8..ad40463 100644 --- a/src/str/regex.rs +++ b/src/str/regex.rs @@ -8,9 +8,9 @@ use std::fmt; +use crate::Predicate; use crate::reflection; use crate::utils; -use crate::Predicate; /// An error that occurred during parsing or compiling a regular expression. pub type RegexError = regex::Error; diff --git a/src/utils.rs b/src/utils.rs index 121f757..4e66d99 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,8 +8,8 @@ use std::fmt; -use crate::reflection; use crate::Predicate; +use crate::reflection; #[derive(Clone, PartialEq, Eq)] pub(crate) struct DebugAdapter