diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-09 13:19:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 13:19:19 +0000 |
commit | 5faa4abc9f957e53ea0e20ad03c8abca201b67b3 (patch) | |
tree | 1905dbcf1286bd976e1431bcb4ec66059556bad5 | |
parent | 10ef97e987efff92aa23ba7b46d0158343acaab0 (diff) | |
parent | 8f59cadac708887f4f8e9a526ef8e30002ad455c (diff) |
Merge #1
1: Actions r=matthiasbeyer a=matthiasbeyer
Github actions implementation.
Co-authored-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | .github/ISSUE_TEMPLATE.md | 12 | ||||
-rw-r--r-- | .github/PULL_REQUEST_TEMPLATE.md | 12 | ||||
-rw-r--r-- | .github/workflows/block-fixup.yml | 13 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 156 | ||||
-rw-r--r-- | .gitlint | 136 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | bors.toml | 7 | ||||
-rw-r--r-- | deny.toml | 65 | ||||
-rw-r--r-- | src/failable/filter.rs | 119 | ||||
-rw-r--r-- | src/failable/mod.rs | 1 | ||||
-rw-r--r-- | src/failable/ops/and.rs | 10 | ||||
-rw-r--r-- | src/failable/ops/bool.rs | 7 | ||||
-rw-r--r-- | src/failable/ops/map.rs | 16 | ||||
-rw-r--r-- | src/failable/ops/mod.rs | 4 | ||||
-rw-r--r-- | src/failable/ops/not.rs | 7 | ||||
-rw-r--r-- | src/failable/ops/or.rs | 10 | ||||
-rw-r--r-- | src/failable/ops/xor.rs | 11 | ||||
-rw-r--r-- | src/filter.rs | 237 | ||||
-rw-r--r-- | src/impl_traits.rs | 1 | ||||
-rw-r--r-- | src/iter.rs | 135 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/ops/and.rs | 4 | ||||
-rw-r--r-- | src/ops/bool.rs | 6 | ||||
-rw-r--r-- | src/ops/failable.rs | 10 | ||||
-rw-r--r-- | src/ops/map.rs | 11 | ||||
-rw-r--r-- | src/ops/mod.rs | 4 | ||||
-rw-r--r-- | src/ops/not.rs | 4 | ||||
-rw-r--r-- | src/ops/or.rs | 4 | ||||
-rw-r--r-- | src/ops/xor.rs | 4 |
29 files changed, 713 insertions, 303 deletions
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index ef4b5f0..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,12 +0,0 @@ -<!-- - -IMPORTANT NOTICE - -Github is only used for CI right now, main development continues on the -mailinglist. - -Please send issues and pull requests (either via `git request-pull` or `git -format-patch` + `git send-email`) to -[the imag mailinglist](https://imag-pim.org/mailinglist/). - ---> diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9b8f367..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,12 +0,0 @@ -<!-- - -IMPORTANT NOTICE - -Github is only used for CI right now, main development continues on -sourcehut. - -Please send patches to: - - https://lists.sr.ht/~matthiasbeyer/filters - ---> diff --git a/.github/workflows/block-fixup.yml b/.github/workflows/block-fixup.yml new file mode 100644 index 0000000..8bf5e23 --- /dev/null +++ b/.github/workflows/block-fixup.yml @@ -0,0 +1,13 @@ +name: Block Fixup commits + +on: + pull_request: + +jobs: + block-fixup: + name: block fixup commits + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: 13rac1/block-fixup-merge-action@v2.0.0 + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cc060ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,156 @@ +name: "CI" + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: check + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - 1.60.0 + - stable + - beta + # - nightly + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - uses: swatinem/rust-cache@v1 + - name: cargo-check + uses: actions-rs/cargo@v1 + with: + command: check + + deny: + name: deny + needs: check + runs-on: ubuntu-latest + strategy: + matrix: + checks: + - advisories + - bans licenses sources + + # Prevent sudden announcement of a new advisory from failing ci: + continue-on-error: ${{ matrix.checks == 'advisories' }} + + steps: + - uses: actions/checkout@v3 + - name: cargo-deny + uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check ${{ matrix.checks }} + + + fmt: + name: format + needs: check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.60.0 + - run: rustup component add rustfmt + - name: cargo-fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + + doc: + name: doc + runs-on: ubuntu-latest + needs: check + + steps: + - uses: actions/checkout@v3 + - name: cargo-doc + uses: actions-rs/cargo@v1 + with: + command: doc + args: --workspace --no-deps --document-private-items + + test: + needs: check + name: test + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - 1.60.0 + - stable + - beta + # - nightly + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - uses: swatinem/rust-cache@v1 + - name: cargo-test + uses: actions-rs/cargo@v1 + with: + command: test + args: --all + + clippy: + needs: check + name: clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.60.0 + override: true + - uses: swatinem/rust-cache@v1 + - run: rustup component add clippy + - name: cargo-clippy + run: cargo clippy --all --all-targets -- -D warnings + + dco-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v4.0.0 + with: + python-version: '3.x' + - name: Install gitlint + run: pip install gitlint + - run: gitlint --commits $(git merge-base origin/master HEAD).. + + ci: + name: CI + if: ${{ success() }} + needs: + - check + - clippy + - dco-check + - deny + - doc + - fmt + - test + runs-on: ubuntu-latest + steps: + - name: CI succeeded + run: exit 0 + diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..56e101f --- /dev/null +++ b/.gitlint @@ -0,0 +1,136 @@ +# Edit this file as you like. +# +# All these sections are optional. Each section with the exception of [general] represents +# one rule and each key in it is an option for that specific rule. +# +# Rules and sections can be referenced by their full name or by id. For example +# section "[body-max-line-length]" could also be written as "[B1]". Full section names are +# used in here for clarity. +# +[general] +# Ignore certain rules, this example uses both full name and id +ignore=body-is-missing + +# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this +# verbosity = 2 + +# By default gitlint will ignore merge, revert, fixup and squash commits. +ignore-merge-commits=true +# ignore-revert-commits=true +# ignore-fixup-commits=true +# ignore-squash-commits=true + +# Ignore any data send to gitlint via stdin +# ignore-stdin=true + +# Fetch additional meta-data from the local repository when manually passing a +# commit message to gitlint via stdin or --commit-msg. Disabled by default. +# staged=true + +# Hard fail when the target commit range is empty. Note that gitlint will +# already fail by default on invalid commit ranges. This option is specifically +# to tell gitlint to fail on *valid but empty* commit ranges. +# Disabled by default. +# fail-without-commits=true + +# Enable debug mode (prints more output). Disabled by default. +# debug=true + +# Enable community contributed rules +# See http://jorisroovers.github.io/gitlint/contrib_rules for details +contrib=CC1 + +# Set the extra-path where gitlint will search for user defined rules +# See http://jorisroovers.github.io/gitlint/user_defined_rules for details +# extra-path=examples/ + +# This is an example of how to configure the "title-max-length" rule and +# set the line-length it enforces to 50 +# [title-max-length] +# line-length=50 + +# Conversely, you can also enforce minimal length of a title with the +# "title-min-length" rule: +# [title-min-length] +# min-length=5 + +# [title-must-not-contain-word] +# Comma-separated list of words that should not occur in the title. Matching is case +# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" +# will not cause a violation, but "WIP: my title" will. +# words=wip + +# [title-match-regex] +# python-style regex that the commit-msg title must match +# Note that the regex can contradict with other rules if not used correctly +# (e.g. title-must-not-contain-word). +# regex=^US[0-9]* + +# [body-max-line-length] +# line-length=72 + +# [body-min-length] +# min-length=5 + +# [body-is-missing] +# Whether to ignore this rule on merge commits (which typically only have a title) +# default = True +# ignore-merge-commits=false + +# [body-changed-file-mention] +# List of files that need to be explicitly mentioned in the body when they are changed +# This is useful for when developers often erroneously edit certain files or git submodules. +# By specifying this rule, developers can only change the file when they explicitly reference +# it in the commit message. +# files=gitlint-core/gitlint/rules.py,README.md + +# [body-match-regex] +# python-style regex that the commit-msg body must match. +# E.g. body must end in My-Commit-Tag: foo +# regex=My-Commit-Tag: foo$ + +# [author-valid-email] +# python-style regex that the commit author email address must match. +# For example, use the following regex if you only want to allow email addresses from foo.com +# regex=[^@]+@foo.com + +# [ignore-by-title] +# Ignore certain rules for commits of which the title matches a regex +# E.g. Match commit titles that start with "Release" +# regex=^Release(.*) + +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# [ignore-by-body] +# Ignore certain rules for commits of which the body has a line that matches a regex +# E.g. Match bodies that have a line that that contain "release" +# regex=(.*)release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# [ignore-body-lines] +# Ignore certain lines in a commit body that match a regex. +# E.g. Ignore all lines that start with 'Co-Authored-By' +# regex=^Co-Authored-By + +# [ignore-by-author-name] +# Ignore certain rules for commits of which the author name matches a regex +# E.g. Match commits made by dependabot +# regex=(.*)dependabot(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# This is a contrib rule - a community contributed rule. These are disabled by default. +# You need to explicitly enable them one-by-one by adding them to the "contrib" option +# under [general] section above. +# [contrib-title-conventional-commits] +# Specify allowed commit types. For details see: https://www.conventionalcommits.org/ +# types = bugfix,user-story,epic +[contrib-body-requires-signed-off-by] + @@ -1,6 +1,7 @@ [package] name = "filters" version = "0.4.0" +edition = "2021" authors = ["Matthias Beyer <mail@beyermatthias.de>", "Marcel Müller <neikos@neikos.email>" ] @@ -11,6 +12,7 @@ readme = "./README.md" license = "MPL-2.0" repository = "https://git.beyermatthi.as/filters" + [dependencies] [features] diff --git a/bors.toml b/bors.toml new file mode 100644 index 0000000..04c0c6f --- /dev/null +++ b/bors.toml @@ -0,0 +1,7 @@ +# Must pass on the merge with the master branch +status = [ + "CI" +] + +delete_merged_branches = true + diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..440880e --- /dev/null +++ b/deny.toml @@ -0,0 +1,65 @@ +[licenses] +# The lint level for crates which do not have a detectable license +unlicensed = "deny" + +# List of explictly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.7 short identifier (+ optional exception)]. +allow = ["MPL-2.0"] + +# List of explictly disallowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.7 short identifier (+ optional exception)]. +deny = [] + +# The lint level for licenses considered copyleft +copyleft = "deny" + +# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses +# * both - The license will only be approved if it is both OSI-approved *AND* FSF/Free +# * either - The license will be approved if it is either OSI-approved *OR* FSF/Free +# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF/Free +# * fsf-only - The license will be approved if is FSF/Free *AND NOT* OSI-approved +# * neither - The license will be denied if is FSF/Free *OR* OSI-approved +allow-osi-fsf-free = "either" + +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 + +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" + +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" + +# List of crates that are allowed. Use with care! +allow = [ +] + +# List of crates to deny +deny = [ +] + +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ +] + +# Similarly to `skip` allows you to skip certain crates during duplicate detection, +# unlike skip, it also includes the entire tree of transitive dependencies starting at +# the specified crate, up to a certain depth, which is by default infinite +skip-tree = [ +] + + +[advisories] +ignore = [ +] + diff --git a/src/failable/filter.rs b/src/failable/filter.rs index 3917a61..fef191c 100644 --- a/src/failable/filter.rs +++ b/src/failable/filter.rs @@ -6,12 +6,12 @@ use std::borrow::Borrow; -pub use failable::ops::and::FailableAnd; -pub use failable::ops::bool::FailableBool; -pub use failable::ops::not::FailableNot; -pub use failable::ops::xor::FailableXOr; -pub use failable::ops::or::FailableOr; -pub use failable::ops::map::{FailableMapInput, FailableMapErr}; +pub use crate::failable::ops::and::FailableAnd; +pub use crate::failable::ops::bool::FailableBool; +pub use crate::failable::ops::map::{FailableMapErr, FailableMapInput}; +pub use crate::failable::ops::not::FailableNot; +pub use crate::failable::ops::or::FailableOr; +pub use crate::failable::ops::xor::FailableXOr; /// Trait for converting something into a Filter pub trait IntoFailableFilter<N> { @@ -33,7 +33,7 @@ pub trait FailableFilter<N> { type Error: Sized; /// The function which is used to filter something - fn filter(&self, &N) -> Result<bool, Self::Error>; + fn filter(&self, _: &N) -> Result<bool, Self::Error>; /// Helper to invert a filter. /// @@ -48,7 +48,8 @@ pub trait FailableFilter<N> { /// assert!(f.filter(&2).unwrap()); /// ``` fn not(self) -> FailableNot<Self> - where Self: Sized + where + Self: Sized, { FailableNot::new(self) } @@ -70,8 +71,9 @@ pub trait FailableFilter<N> { /// assert!(!c.filter(&7).unwrap()); /// ``` fn or<F>(self, other: F) -> FailableOr<Self, F::IntoFilt> - where Self: Sized, - F: IntoFailableFilter<N> + Sized + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, { FailableOr::new(self, other.into_failable_filter()) } @@ -93,8 +95,9 @@ pub trait FailableFilter<N> { /// assert!(c.filter(&7).unwrap()); /// ``` fn or_not<F>(self, other: F) -> FailableOr<Self, FailableNot<F::IntoFilt>> - where Self: Sized, - F: IntoFailableFilter<N> + Sized, + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, { self.or(FailableNot::new(other.into_failable_filter())) } @@ -117,12 +120,20 @@ pub trait FailableFilter<N> { /// assert!(d.filter(&3).unwrap()); /// assert!(!d.filter(&4).unwrap()); /// ``` - fn or3<F, F2>(self, other: F, other2: F2) -> FailableOr<Self, FailableOr<F::IntoFilt, F2::IntoFilt>> - where Self: Sized, - F: IntoFailableFilter<N> + Sized, - F2: IntoFailableFilter<N> + Sized + fn or3<F, F2>( + self, + other: F, + other2: F2, + ) -> FailableOr<Self, FailableOr<F::IntoFilt, F2::IntoFilt>> + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, + F2: IntoFailableFilter<N> + Sized, { - FailableOr::new(self, FailableOr::new(other.into_failable_filter(), other2.into_failable_filter())) + FailableOr::new( + self, + FailableOr::new(other.into_failable_filter(), other2.into_failable_filter()), + ) } /// Helper to connect two filters via logical NOR @@ -143,7 +154,8 @@ pub trait FailableFilter<N> { /// assert!(c.filter(&4).unwrap()); /// ``` fn nor<F>(self, other: F) -> FailableNot<FailableOr<Self, F>> - where Self: Sized, + where + Self: Sized, { FailableNot::new(FailableOr::new(self, other)) } @@ -167,7 +179,8 @@ pub trait FailableFilter<N> { /// assert!(c.filter(&9).unwrap()); /// ``` fn xor<F>(self, other: F) -> FailableXOr<Self, F> - where Self: Sized, + where + Self: Sized, { FailableXOr::new(self, other) } @@ -191,8 +204,9 @@ pub trait FailableFilter<N> { /// assert!(!c.filter(&9).unwrap()); /// ``` fn and<F>(self, other: F) -> FailableAnd<Self, F::IntoFilt> - where Self: Sized, - F: IntoFailableFilter<N> + Sized + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, { FailableAnd::new(self, other.into_failable_filter()) } @@ -218,12 +232,20 @@ pub trait FailableFilter<N> { /// assert!(!d.filter(&15).unwrap()); /// assert!(!d.filter(&19).unwrap()); /// ``` - fn and3<F, F2>(self, other: F, other2: F2) -> FailableAnd<Self, FailableAnd<F::IntoFilt, F2::IntoFilt>> - where Self: Sized, - F: IntoFailableFilter<N> + Sized, - F2: IntoFailableFilter<N> + Sized + fn and3<F, F2>( + self, + other: F, + other2: F2, + ) -> FailableAnd<Self, FailableAnd<F::IntoFilt, F2::IntoFilt>> + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, + F2: IntoFailableFilter<N> + Sized, { - FailableAnd::new(self, FailableAnd::new(other.into_failable_filter(), other2.into_failable_filter())) + FailableAnd::new( + self, + FailableAnd::new(other.into_failable_filter(), other2.into_failable_filter()), + ) } /// Helper to connect two filters via logical AND and NOT @@ -247,8 +269,9 @@ pub trait FailableFilter<N> { /// assert!(c.filter(&29).unwrap()); /// ``` fn and_not<F>(self, other: F) -> FailableAnd<Self, FailableNot<F::IntoFilt>> - where Self: Sized, - F: IntoFailableFilter<N> + Sized + where + Self: Sized, + F: IntoFailableFilter<N> + Sized, { self.and(FailableNot::new(other.into_failable_filter())) } @@ -274,7 +297,8 @@ pub trait FailableFilter<N> { /// assert!(c.filter(&29).unwrap()); /// ``` fn nand<F>(self, other: F) -> FailableNot<FailableAnd<Self, F>> - where Self: Sized, + where + Self: Sized, { FailableNot::new(FailableAnd::new(self, other)) } @@ -299,9 +323,10 @@ pub trait FailableFilter<N> { /// assert!(!c.filter(&9).unwrap()); /// ``` fn map_input<O, B, T, M>(self, map: M) -> FailableMapInput<Self, M, O, B> - where Self: Sized, - M: Fn(&T) -> N, - B: Borrow<O> + Sized + where + Self: Sized, + M: Fn(&T) -> N, + B: Borrow<O> + Sized, { FailableMapInput::new(self, map) } @@ -327,17 +352,18 @@ pub trait FailableFilter<N> { /// assert!(!c.filter(&9).unwrap()); /// ``` fn map_err<M, OE>(self, map: M) -> FailableMapErr<Self, M, OE> - where Self: Sized, - M: Fn(Self::Error) -> OE + where + Self: Sized, + M: Fn(Self::Error) -> OE, { FailableMapErr::new(self, map) } - } /// All closures that take a ref to something and return Result<bool, E> are failable filters impl<I, E, T> FailableFilter<I> for T - where T: Fn(&I) -> Result<bool, E> +where + T: Fn(&I) -> Result<bool, E>, { type Error = E; @@ -351,7 +377,7 @@ mod tests { use super::*; #[derive(Debug)] - struct StupError { } + struct StupError {} #[test] fn compile_test() { @@ -393,33 +419,30 @@ mod tests { #[test] fn test_both_filter_types() { - use filter::Filter; + use crate::filter::Filter; let a = |_: &i32| -> Result<bool, StupError> { Ok(true) }; let b = |_: &i32| -> bool { true }; let c = |_: &i32| -> Result<bool, StupError> { Ok(true) }; let d = |_: &i32| -> bool { false }; - let e = a // true - .and(b.into_failable().map_err(|_| StupError {})) // true - .xor(c) // true - .or(d.into_failable().map_err(|_| StupError {})); // true + let e = a // true + .and(b.into_failable().map_err(|_| StupError {})) // true + .xor(c) // true + .or(d.into_failable().map_err(|_| StupError {})); // true assert!(!e.filter(&1).unwrap()); } - #[test] fn test_both_filter_types_in_one_scope() { - use filter::Filter; - use failable::filter::FailableFilter; + use crate::failable::filter::FailableFilter; + use crate::filter::Filter; - let failable = |_: &i32| -> Result<bool, StupError> { Ok(true) }; + let failable = |_: &i32| -> Result<bool, StupError> { Ok(true) }; let unfailable = |_: &i32| -> bool { true }; assert!(failable.filter(&1).unwrap()); assert!(unfailable.filter(&1)); - } } - diff --git a/src/failable/mod.rs b/src/failable/mod.rs index 2ae44a6..6380a7b 100644 --- a/src/failable/mod.rs +++ b/src/failable/mod.rs @@ -6,4 +6,3 @@ pub mod filter; pub mod ops; - diff --git a/src/failable/ops/and.rs b/src/failable/ops/and.rs index f0a1584..f8d4636 100644 --- a/src/failable/ops/and.rs +++ b/src/failable/ops/and.rs @@ -10,23 +10,22 @@ //! shouldn't be necessary. //! -use failable::filter::FailableFilter; +use crate::failable::filter::FailableFilter; #[must_use = "filters are lazy and do nothing unless consumed"] #[derive(Clone)] pub struct FailableAnd<T, U>(T, U); impl<T, U> FailableAnd<T, U> { - pub fn new(a: T, b: U) -> FailableAnd<T, U> { FailableAnd(a, b) } - } impl<N, T, U, E> FailableFilter<N> for FailableAnd<T, U> - where T: FailableFilter<N, Error = E>, - U: FailableFilter<N, Error = E> +where + T: FailableFilter<N, Error = E>, + U: FailableFilter<N, Error = E>, { type Error = E; @@ -34,4 +33,3 @@ impl<N, T, U, E> FailableFilter<N> for FailableAnd<T, U> Ok(self.0.filter(e)? && self.1.filter(e)?) } } - diff --git a/src/failable/ops/bool.rs b/src/failable/ops/bool.rs index ad68f63..e0186f1 100644 --- a/src/failable/ops/bool.rs +++ b/src/failable/ops/bool.rs @@ -10,26 +10,22 @@ //! shouldn't be necessary. //! -use failable::filter::FailableFilter; +use crate::failable::filter::FailableFilter; #[must_use = "filters are lazy and do nothing unless consumed"] #[derive(Clone)] pub struct FailableBool(bool); impl FailableBool { - pub fn new(b: bool) -> FailableBool { FailableBool(b) } - } impl From<bool> for FailableBool { - fn from(b: bool) -> FailableBool { FailableBool::new(b) } - } impl<N> FailableFilter<N> for FailableBool { @@ -39,4 +35,3 @@ impl<N> FailableFilter<N> for FailableBool { Ok(self.0) } } - diff --git a/src/failable/ops/map.rs b/src/failable/ops/map.rs index 8dd3cc5..5b28c03 100644 --- a/src/failable/ops/map.rs +++ b/src/failable/ops/map.rs @@ -9,10 +9,10 @@ //! Will be automatically included when including `filter::Filter`, so importing this module //! shouldn't be necessary. //! -use std::marker::PhantomData; use std::borrow::Borrow; +use std::marker::PhantomData; -use failable::filter::FailableFilter; +use crate::failable::filter::FailableFilter; #[must_use = "filters are lazy and do nothing unless consumed"] #[derive(Clone)] @@ -25,9 +25,10 @@ impl<F, M, FT, B> FailableMapInput<F, M, FT, B> { } impl<FT, F, T, B, M> FailableFilter<T> for FailableMapInput<F, M, FT, B> - where F: FailableFilter<FT>, - B: Borrow<FT> + Sized, - M: Fn(&T) -> B +where + F: FailableFilter<FT>, + B: Borrow<FT> + Sized, + M: Fn(&T) -> B, { type Error = F::Error; @@ -47,8 +48,9 @@ impl<F, M, E> FailableMapErr<F, M, E> { } impl<E, F, T, M> FailableFilter<T> for FailableMapErr<F, M, E> - where F: FailableFilter<T>, - M: Fn(F::Error) -> E +where + F: FailableFilter<T>, + M: Fn(F::Error) -> E, { type Error = E; diff --git a/src/failable/ops/mod.rs b/src/failable/ops/mod.rs index 618c0e8..c8c2c28 100644 --- a/src/failable/ops/mod.rs +++ b/src/failable/ops/mod.rs @@ -6,7 +6,7 @@ pub mod and; pub mod bool; +pub mod map; pub mod not; -pub mod xor; pub mod or; -pub mod map; +pub mod xor; diff --git a/src/failable/ops/not.rs b/src/failable/ops/not.rs index bc55230..3297605 100644 --- a/src/failable/ops/not.rs +++ b/src/failable/ops/not.rs @@ -10,22 +10,21 @@ //! shouldn't be necessary. //! -use failable::filter::FailableFilter; +use crate::failable::filter::FailableFilter; #[must_use = "filters are lazy and do nothing unless consumed"] #[derive(Clone)] pub struct FailableNot<T>(T); impl<T> FailableNot<T> { - pub fn new(a: T) -> FailableNot<T> { FailableNot(a) } - } impl<N, T> FailableFilter<N> for FailableNot<T> - where T: FailableFilter<N> +where + T: FailableFilter<N>, { type Error = T::Error; diff --git a/src/failable/ops/or.rs b/src/failable/ops/or.rs index 9cebc75..6927af9 100644 --- a/src/failable/ops/or.rs +++ b/src/failable/ops/or.rs |