From c12522f7bfe5c479e5cf41a8b1e3e77d0611a1ed Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 20 Jan 2024 15:17:39 -0800 Subject: [PATCH 1/3] Add/fix some documentation links --- src/lib.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d7fbf2c..707c562 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,11 +88,11 @@ macro_rules! for_both { }; } -/// Macro for unwrapping the left side of an `Either`, which fails early +/// Macro for unwrapping the left side of an [`Either`], which fails early /// with the opposite side. Can only be used in functions that return /// `Either` because of the early return of `Right` that it provides. /// -/// See also `try_right!` for its dual, which applies the same just to the +/// See also [`try_right!`] for its dual, which applies the same just to the /// right side. /// /// # Example @@ -120,7 +120,7 @@ macro_rules! try_left { }; } -/// Dual to `try_left!`, see its documentation for more information. +/// Dual to [`try_left!`], see its documentation for more information. #[macro_export] macro_rules! try_right { ($expr:expr) => { @@ -376,7 +376,7 @@ impl Either { } } - /// Similar to [`map_either`], with an added context `ctx` accessible to + /// Similar to [`map_either`][Self::map_either], with an added context `ctx` accessible to /// both functions. /// /// ``` @@ -434,7 +434,7 @@ impl Either { } } - /// Like `either`, but provide some context to whichever of the + /// Like [`either`][Self::either], but provide some context to whichever of the /// functions ends up being called. /// /// ``` @@ -531,10 +531,8 @@ impl Either { /// Return left value or given value /// /// Arguments passed to `left_or` are eagerly evaluated; if you are passing - /// the result of a function call, it is recommended to use [`left_or_else`], - /// which is lazily evaluated. - /// - /// [`left_or_else`]: #method.left_or_else + /// the result of a function call, it is recommended to use + /// [`left_or_else`][Self::left_or_else], which is lazily evaluated. /// /// # Examples /// @@ -600,10 +598,8 @@ impl Either { /// Return right value or given value /// /// Arguments passed to `right_or` are eagerly evaluated; if you are passing - /// the result of a function call, it is recommended to use [`right_or_else`], - /// which is lazily evaluated. - /// - /// [`right_or_else`]: #method.right_or_else + /// the result of a function call, it is recommended to use + /// [`right_or_else`][Self::right_or_else], which is lazily evaluated. /// /// # Examples /// From 35a1e74a34228194d5a5e27403f431d9f8d771b4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 20 Jan 2024 15:18:21 -0800 Subject: [PATCH 2/3] Note `use_std` required for `Error` --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 707c562..6ead020 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1333,6 +1333,8 @@ where #[cfg(any(test, feature = "use_std"))] /// `Either` implements `Error` if *both* `L` and `R` implement it. +/// +/// Requires crate feature `"use_std"` impl Error for Either where L: Error, From 1cb6cf53431b869e499e704d05641eef853153f5 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 20 Jan 2024 15:18:49 -0800 Subject: [PATCH 3/3] Tighten allowed lints on test `error` --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6ead020..4c940fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1475,9 +1475,9 @@ fn read_write() { } #[test] -#[allow(deprecated)] fn error() { let invalid_utf8 = b"\xff"; + #[allow(invalid_from_utf8)] let res = if let Err(error) = ::std::str::from_utf8(invalid_utf8) { Err(Left(error)) } else if let Err(error) = "x".parse::() { @@ -1486,6 +1486,7 @@ fn error() { Ok(()) }; assert!(res.is_err()); + #[allow(deprecated)] res.unwrap_err().description(); // make sure this can be called }