Skip to content

Commit

Permalink
release: 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Sep 5, 2024
2 parents 37f4c0a + 85c9879 commit 0f0359f
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@



## [0.4.0](https://github.com/Blobfolio/later_operator/releases/tag/v0.4.0) - 2024-09-05

### Changed

* `Error` is now zst
* Bump MSRV to `1.81`
* Miscellaneous code cleanup and lints



## [0.3.0](https://github.com/Blobfolio/later_operator/releases/tag/v0.3.0) - 2024-07-28

### Changed
Expand Down
4 changes: 2 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Dependencies
Package: later_operator
Version: 0.3.0
Generated: 2024-07-29 06:43:26 UTC
Version: 0.4.0
Generated: 2024-09-05 19:36:01 UTC

This package has no dependencies.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "later_operator"
version = "0.3.0"
version = "0.4.0"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.80"
rust-version = "1.81"
description = "Parsable, storable, printable comparison operators, w/ optional serde support."
license = "WTFPL"
repository = "https://github.com/Blobfolio/later_operator"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Add `later_operator` to your `dependencies` in `Cargo.toml`, like:

```toml
[dependencies]
later_operator = "0.3.*"
later_operator = "0.4.*"
```


Expand Down
3 changes: 2 additions & 1 deletion src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl TryFrom<&[u8]> for ComparisonOperator {
b"==" | b"=" => Ok(Self::Eq),
b">=" => Ok(Self::Ge),
b">" => Ok(Self::Gt),
_ => Err(Error::ComparisonOperator),
_ => Err(Error),
}
}
}
Expand Down Expand Up @@ -168,6 +168,7 @@ impl ComparisonOperator {
}
}

/// # Helper: Generate Is Equal/Less/Etc. Methods.
macro_rules! is {
($name:literal, $fn:ident, $ty:ident) => (
#[must_use]
Expand Down
13 changes: 3 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ use crate::macros;



#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy)]
/// # Error.
pub enum Error {
ComparisonOperator,
}
pub struct Error;

macros::as_ref_borrow!(Error, as_str, str);
macros::display_str!(Error, as_str);
Expand All @@ -23,9 +20,5 @@ impl Error {
/// # As Str.
///
/// Return the error as a string slice.
pub const fn as_str(self) -> &'static str {
match self {
Self::ComparisonOperator => "unable to parse comparison operator",
}
}
pub const fn as_str(self) -> &'static str { "unable to parse comparison operator" }
}
39 changes: 31 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,53 @@ assert!(ComparisonOperator::try_from("~").is_err());

#![forbid(unsafe_code)]

#![deny(
clippy::allow_attributes_without_reason,
clippy::correctness,
unreachable_pub,
)]

#![warn(
clippy::filetype_is_file,
clippy::integer_division,
clippy::needless_borrow,
clippy::complexity,
clippy::nursery,
clippy::pedantic,
clippy::perf,
clippy::suboptimal_flops,
clippy::style,
clippy::allow_attributes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::filetype_is_file,
clippy::format_push_string,
clippy::get_unwrap,
clippy::impl_trait_in_params,
clippy::lossy_float_literal,
clippy::missing_assert_message,
clippy::missing_docs_in_private_items,
clippy::needless_raw_strings,
clippy::panic_in_result_fn,
clippy::pub_without_shorthand,
clippy::rest_pat_in_fully_bound_structs,
clippy::semicolon_inside_block,
clippy::str_to_string,
clippy::string_to_string,
clippy::todo,
clippy::undocumented_unsafe_blocks,
clippy::unneeded_field_pattern,
clippy::unseparated_literal_suffix,
clippy::unwrap_in_result,
macro_use_extern_crate,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
)]

#![allow(clippy::module_name_repetitions)]

#![cfg_attr(docsrs, feature(doc_cfg))]

mod cmp;
Expand Down
12 changes: 12 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
# Later Operator: Macros
*/

/// # Helper: Generate `AsRef`/`Borrow` impls.
macro_rules! as_ref_borrow {
($from:ty, $fn:ident, $to:ty) => (
#[inline]
impl AsRef<$to> for $from {
fn as_ref(&self) -> &$to { self.$fn() }
}
#[inline]
impl ::std::borrow::Borrow<$to> for $from {
fn borrow(&self) -> &$to { self.$fn() }
}
);
}

#[cfg(feature = "serde")]
/// # Helper: Deserialize as String.
macro_rules! deserialize_str {
($ty:ty, $fn:ident) => (
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
Expand Down Expand Up @@ -46,37 +50,45 @@ macro_rules! deserialize_str {
);
}

/// # Helper: Display as String.
macro_rules! display_str {
($ty:ty, $fn:ident) => (
impl ::std::fmt::Display for $ty {
#[inline]
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str(self.$fn())
}
}
);
}

/// # Helper: From String.
macro_rules! from_str {
($ty:ty, $fn:ident) => (
#[inline]
impl ::std::str::FromStr for $ty {
type Err = $crate::Error;
fn from_str(src: &str) -> Result<Self, Self::Err> { Self::$fn(src) }
}
);
}

/// # Helper: Symmetrical `PartialEq`.
macro_rules! partial_eq {
($from:ty, $fn:ident, $to:ty) => (
#[inline]
impl PartialEq<$to> for $from {
fn eq(&self, other: &$to) -> bool { self.$fn() == other }
}
#[inline]
impl PartialEq<$from> for $to {
fn eq(&self, other: &$from) -> bool { self == other.$fn() }
}
);
}

#[cfg(feature = "serde")]
/// # Helper: Serialize as String.
macro_rules! serialize_str {
($ty:ty, $fn:ident) => (
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
Expand Down

0 comments on commit 0f0359f

Please sign in to comment.