Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

64
vendor/derive_more/src/add.rs vendored Normal file
View File

@@ -0,0 +1,64 @@
//! Definitions used in derived implementations of [`core::ops::Add`]-like traits.
use core::fmt;
use crate::UnitError;
/// Error returned by the derived implementations when an arithmetic or logic
/// operation is invoked on mismatched enum variants.
#[derive(Clone, Copy, Debug)]
pub struct WrongVariantError {
operation_name: &'static str,
}
impl WrongVariantError {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(operation_name: &'static str) -> Self {
Self { operation_name }
}
}
impl fmt::Display for WrongVariantError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Trying to {}() mismatched enum variants",
self.operation_name,
)
}
}
#[cfg(feature = "std")]
impl std::error::Error for WrongVariantError {}
/// Possible errors returned by the derived implementations of binary
/// arithmetic or logic operations.
#[derive(Clone, Copy, Debug)]
pub enum BinaryError {
/// Operation is attempted between mismatched enum variants.
Mismatch(WrongVariantError),
/// Operation is attempted on unit-like enum variants.
Unit(UnitError),
}
impl fmt::Display for BinaryError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Mismatch(e) => write!(f, "{e}"),
Self::Unit(e) => write!(f, "{e}"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for BinaryError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Mismatch(e) => e.source(),
Self::Unit(e) => e.source(),
}
}
}

78
vendor/derive_more/src/as.rs vendored Normal file
View File

@@ -0,0 +1,78 @@
//! Type glue for [autoref-based specialization][0], used in [`AsRef`]/[`AsMut`] macro expansion.
//!
//! Allows tp specialize the `impl<T> AsRef<T> for T` case over the default
//! `impl<Inner: AsRef<B>, B> AsRef<B> for Outer<Inner>` one.
//!
//! [0]: https://lukaskalbertodt.github.io/2019/12/05/generalized-autoref-based-specialization.html
use core::marker::PhantomData;
/// Container to specialize over.
pub struct Conv<Frm: ?Sized, To: ?Sized>(PhantomData<(*const Frm, *const To)>);
impl<Frm: ?Sized, To: ?Sized> Default for Conv<Frm, To> {
fn default() -> Self {
Self(PhantomData)
}
}
/// Trait performing the specialization.
pub trait ExtractRef {
/// Input reference type.
type Frm;
/// Output reference type.
type To;
/// Extracts the output type from the input one.
fn __extract_ref(&self, frm: Self::Frm) -> Self::To;
}
impl<'a, T> ExtractRef for &Conv<&'a T, T>
where
T: ?Sized,
{
type Frm = &'a T;
type To = &'a T;
fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
frm
}
}
impl<'a, Frm, To> ExtractRef for Conv<&'a Frm, To>
where
Frm: AsRef<To> + ?Sized,
To: ?Sized + 'a,
{
type Frm = &'a Frm;
type To = &'a To;
fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
frm.as_ref()
}
}
impl<'a, T> ExtractRef for &Conv<&'a mut T, T>
where
T: ?Sized,
{
type Frm = &'a mut T;
type To = &'a mut T;
fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
frm
}
}
impl<'a, Frm, To> ExtractRef for Conv<&'a mut Frm, To>
where
Frm: AsMut<To> + ?Sized,
To: ?Sized + 'a,
{
type Frm = &'a mut Frm;
type To = &'a mut To;
fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
frm.as_mut()
}
}

97
vendor/derive_more/src/convert.rs vendored Normal file
View File

@@ -0,0 +1,97 @@
//! Definitions used in derived implementations of [`core::convert`] traits.
#[cfg(feature = "try_from")]
pub use self::try_from::TryFromReprError;
#[cfg(feature = "try_into")]
pub use self::try_into::TryIntoError;
#[cfg(feature = "try_from")]
mod try_from {
use core::fmt;
/// Error returned by the derived [`TryFrom`] implementation on enums to
/// convert from their repr.
///
/// [`TryFrom`]: macro@crate::TryFrom
#[derive(Clone, Copy, Debug)]
pub struct TryFromReprError<T> {
/// Original input value which failed to convert via the derived
/// [`TryFrom`] implementation.
///
/// [`TryFrom`]: macro@crate::TryFrom
pub input: T,
}
impl<T> TryFromReprError<T> {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(input: T) -> Self {
Self { input }
}
}
// `T`, as a discriminant, should only be an integer type, and therefore be `Debug`.
impl<T: fmt::Debug> fmt::Display for TryFromReprError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"`{:?}` does not correspond to a unit variant",
self.input
)
}
}
#[cfg(feature = "std")]
// `T` should only be an integer type and therefore be debug
impl<T: fmt::Debug> std::error::Error for TryFromReprError<T> {}
}
#[cfg(feature = "try_into")]
mod try_into {
use core::fmt;
/// Error returned by the derived [`TryInto`] implementation.
///
/// [`TryInto`]: macro@crate::TryInto
#[derive(Clone, Copy, Debug)]
pub struct TryIntoError<T> {
/// Original input value which failed to convert via the derived
/// [`TryInto`] implementation.
///
/// [`TryInto`]: macro@crate::TryInto
pub input: T,
variant_names: &'static str,
output_type: &'static str,
}
impl<T> TryIntoError<T> {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(
input: T,
variant_names: &'static str,
output_type: &'static str,
) -> Self {
Self {
input,
variant_names,
output_type,
}
}
}
impl<T> fmt::Display for TryIntoError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Only {} can be converted to {}",
self.variant_names, self.output_type,
)
}
}
#[cfg(feature = "std")]
impl<T: fmt::Debug> std::error::Error for TryIntoError<T> {}
}

189
vendor/derive_more/src/fmt.rs vendored Normal file
View File

@@ -0,0 +1,189 @@
//! [`core::fmt::DebugTuple`] reimplementation with
//! [`DebugTuple::finish_non_exhaustive()`] method.
use ::core;
use core::fmt::{Debug, Formatter, Result, Write};
use core::prelude::v1::*;
/// Same as [`core::fmt::DebugTuple`], but with
/// [`DebugTuple::finish_non_exhaustive()`] method.
#[must_use = "must eventually call `finish()` or `finish_non_exhaustive()` on \
Debug builders"]
pub struct DebugTuple<'a, 'b: 'a> {
fmt: &'a mut Formatter<'b>,
result: Result,
fields: usize,
empty_name: bool,
}
/// Creates a new [`DebugTuple`].
pub fn debug_tuple<'a, 'b>(
fmt: &'a mut Formatter<'b>,
name: &str,
) -> DebugTuple<'a, 'b> {
let result = fmt.write_str(name);
DebugTuple {
fmt,
result,
fields: 0,
empty_name: name.is_empty(),
}
}
impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
/// Adds a new field to the generated tuple struct output.
///
/// # Example
///
/// ```rust
/// use core::fmt;
/// use derive_more::__private::debug_tuple;
///
/// struct Foo(i32, String);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// debug_tuple(fmt, "Foo")
/// .field(&self.0) // We add the first field.
/// .field(&self.1) // We add the second field.
/// .finish() // We're good to go!
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(10, "Hello World".to_string())),
/// "Foo(10, \"Hello World\")",
/// );
/// ```
pub fn field(&mut self, value: &dyn Debug) -> &mut Self {
self.result = self.result.and_then(|_| {
if self.is_pretty() {
if self.fields == 0 {
self.fmt.write_str("(\n")?;
}
let mut padded_formatter = Padded::new(self.fmt);
padded_formatter.write_fmt(format_args!("{value:#?}"))?;
padded_formatter.write_str(",\n")
} else {
let prefix = if self.fields == 0 { "(" } else { ", " };
self.fmt.write_str(prefix)?;
value.fmt(self.fmt)
}
});
self.fields += 1;
self
}
/// Finishes output and returns any error encountered.
///
/// # Example
///
/// ```
/// use core::fmt;
/// use derive_more::__private::debug_tuple;
///
/// struct Foo(i32, String);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// debug_tuple(fmt, "Foo")
/// .field(&self.0)
/// .field(&self.1)
/// .finish() // You need to call it to "finish" the
/// // tuple formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(10, "Hello World".to_string())),
/// "Foo(10, \"Hello World\")",
/// );
/// ```
pub fn finish(&mut self) -> Result {
if self.fields > 0 {
self.result = self.result.and_then(|_| {
if self.fields == 1 && self.empty_name && !self.is_pretty() {
self.fmt.write_str(",")?;
}
self.fmt.write_str(")")
});
}
self.result
}
/// Marks the struct as non-exhaustive, indicating to the reader that there are some other
/// fields that are not shown in the debug representation, and finishes output, returning any
/// error encountered.
///
/// # Example
///
/// ```rust
/// use core::fmt;
/// use derive_more::__private::debug_tuple;
///
/// struct Bar(i32, f32);
///
/// impl fmt::Debug for Bar {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// debug_tuple(fmt, "Bar")
/// .field(&self.0)
/// .finish_non_exhaustive() // Show that some other field(s) exist.
/// }
/// }
///
/// assert_eq!(format!("{:?}", Bar(10, 1.0)), "Bar(10, ..)");
/// ```
pub fn finish_non_exhaustive(&mut self) -> Result {
self.result = self.result.and_then(|_| {
if self.fields > 0 {
if self.is_pretty() {
let mut padded_formatter = Padded::new(self.fmt);
padded_formatter.write_str("..\n")?;
self.fmt.write_str(")")
} else {
self.fmt.write_str(", ..)")
}
} else {
self.fmt.write_str("(..)")
}
});
self.result
}
fn is_pretty(&self) -> bool {
self.fmt.alternate()
}
}
/// Wrapper for a [`Formatter`] adding 4 spaces on newlines for inner pretty
/// printed [`Debug`] values.
struct Padded<'a, 'b> {
formatter: &'a mut Formatter<'b>,
on_newline: bool,
}
impl<'a, 'b> Padded<'a, 'b> {
fn new(formatter: &'a mut Formatter<'b>) -> Self {
Self {
formatter,
on_newline: true,
}
}
}
impl<'a, 'b> Write for Padded<'a, 'b> {
fn write_str(&mut self, s: &str) -> Result {
for s in s.split_inclusive('\n') {
if self.on_newline {
self.formatter.write_str(" ")?;
}
self.on_newline = s.ends_with('\n');
self.formatter.write_str(s)?;
}
Ok(())
}
}

450
vendor/derive_more/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,450 @@
// These links overwrite the ones in `README.md`
// to become proper intra-doc links in Rust docs.
//! [`From`]: macro@crate::From
//! [`Into`]: macro@crate::Into
//! [`FromStr`]: macro@crate::FromStr
//! [`TryFrom`]: macro@crate::TryFrom
//! [`TryInto`]: macro@crate::TryInto
//! [`IntoIterator`]: macro@crate::IntoIterator
//! [`AsRef`]: macro@crate::AsRef
//!
//! [`Debug`]: macro@crate::Debug
//! [`Display`-like]: macro@crate::Display
//!
//! [`Error`]: macro@crate::Error
//!
//! [`Index`]: macro@crate::Index
//! [`Deref`]: macro@crate::Deref
//! [`Not`-like]: macro@crate::Not
//! [`Add`-like]: macro@crate::Add
//! [`Mul`-like]: macro@crate::Mul
//! [`Sum`-like]: macro@crate::Sum
//! [`IndexMut`]: macro@crate::IndexMut
//! [`DerefMut`]: macro@crate::DerefMut
//! [`AddAssign`-like]: macro@crate::AddAssign
//! [`MulAssign`-like]: macro@crate::MulAssign
//!
//! [`Constructor`]: macro@crate::Constructor
//! [`IsVariant`]: macro@crate::IsVariant
//! [`Unwrap`]: macro@crate::Unwrap
//! [`TryUnwrap`]: macro@crate::TryUnwrap
// The README includes doctests requiring these features. To make sure that
// tests pass when not all features are provided we exclude it when the
// required features are not available.
#![cfg_attr(
all(
feature = "add",
feature = "display",
feature = "from",
feature = "into"
),
doc = include_str!("../README.md")
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(any(not(docsrs), ci), deny(rustdoc::all))]
#![forbid(non_ascii_idents, unsafe_code)]
#![warn(clippy::nonstandard_macro_braces)]
// For macro expansion internals only.
// Ensures better hygiene in case a local crate `core` is present in workspace of the user code,
// or some other crate is renamed as `core`.
#[doc(hidden)]
pub use core;
// Not public, but exported API. For macro expansion internals only.
#[doc(hidden)]
pub mod __private {
#[cfg(feature = "as_ref")]
pub use crate::r#as::{Conv, ExtractRef};
#[cfg(feature = "debug")]
pub use crate::fmt::{debug_tuple, DebugTuple};
#[cfg(feature = "error")]
pub use crate::vendor::thiserror::aserror::AsDynError;
}
/// Module containing macro definitions only, without corresponding traits.
///
/// Use it in your import paths, if you don't want to import traits, but only macros.
pub mod derive {
// This can be unused if no feature is enabled. We already error in that case, but this warning
// distracts from that error. So we suppress the warning.
#[allow(unused_imports)]
#[doc(inline)]
pub use derive_more_impl::*;
}
// The modules containing error types and other helpers.
#[cfg(feature = "add")]
mod add;
#[cfg(feature = "add")]
pub use crate::add::{BinaryError, WrongVariantError};
#[cfg(any(feature = "add", feature = "not"))]
mod ops;
#[cfg(any(feature = "add", feature = "not"))]
pub use crate::ops::UnitError;
#[cfg(feature = "as_ref")]
mod r#as;
#[cfg(feature = "debug")]
mod fmt;
#[cfg(feature = "error")]
mod vendor;
#[cfg(feature = "from_str")]
mod r#str;
#[cfg(feature = "from_str")]
#[doc(inline)]
pub use crate::r#str::FromStrError;
#[cfg(any(feature = "try_into", feature = "try_from"))]
mod convert;
#[cfg(feature = "try_from")]
#[doc(inline)]
pub use crate::convert::TryFromReprError;
#[cfg(feature = "try_into")]
#[doc(inline)]
pub use crate::convert::TryIntoError;
#[cfg(feature = "try_unwrap")]
mod try_unwrap;
#[cfg(feature = "try_unwrap")]
#[doc(inline)]
pub use crate::try_unwrap::TryUnwrapError;
// When re-exporting traits from std we need to do a pretty crazy trick, because we ONLY want
// to re-export the traits and not derives that are called the same in the std module,
// because those would conflict with our own. The way we do this is by first importing both
// the trait and possible derive into a separate module and re-export them. Then we wildcard import
// all the things from that module into the main module, but we also import our own derive by its
// exact name. Due to the way wildcard imports work in rust, that results in our own derive taking
// precedence over any derive from std. For some reason the named re-export of our own derive
// cannot be in in this (or really any) macro too. It will somehow still consider it a wildcard
// then and will result in this warning ambiguous_glob_reexports, and not actually exporting of our
// derive.
macro_rules! re_export_traits((
$feature:literal, $new_module_name:ident, $module:path $(, $traits:ident)* $(,)?) => {
#[cfg(all(feature = $feature, any(not(docsrs), ci)))]
mod $new_module_name {
#[doc(hidden)]
pub use $module::{$($traits),*};
}
#[cfg(all(feature = $feature, any(not(docsrs), ci)))]
#[doc(hidden)]
pub use crate::all_traits_and_derives::$new_module_name::*;
}
);
mod all_traits_and_derives {
re_export_traits!(
"add",
add_traits,
core::ops,
Add,
BitAnd,
BitOr,
BitXor,
Sub,
);
re_export_traits!(
"add_assign",
add_assign_traits,
core::ops,
AddAssign,
BitAndAssign,
BitOrAssign,
BitXorAssign,
SubAssign,
);
re_export_traits!("as_ref", as_ref_traits, core::convert, AsMut, AsRef);
re_export_traits!("debug", debug_traits, core::fmt, Debug);
re_export_traits!("deref", deref_traits, core::ops, Deref);
re_export_traits!("deref_mut", deref_mut_traits, core::ops, DerefMut);
re_export_traits!(
"display",
display_traits,
core::fmt,
Binary,
Display,
LowerExp,
LowerHex,
Octal,
Pointer,
UpperExp,
UpperHex,
);
#[cfg(not(feature = "std"))]
re_export_traits!("error", error_traits, core::error, Error);
#[cfg(feature = "std")]
re_export_traits!("error", error_traits, std::error, Error);
re_export_traits!("from", from_traits, core::convert, From);
re_export_traits!("from_str", from_str_traits, core::str, FromStr);
re_export_traits!("index", index_traits, core::ops, Index);
re_export_traits!("index_mut", index_mut_traits, core::ops, IndexMut);
re_export_traits!("into", into_traits, core::convert, Into);
re_export_traits!(
"into_iterator",
into_iterator_traits,
core::iter,
IntoIterator,
);
re_export_traits!("mul", mul_traits, core::ops, Div, Mul, Rem, Shl, Shr);
#[cfg(feature = "mul_assign")]
re_export_traits!(
"mul_assign",
mul_assign_traits,
core::ops,
DivAssign,
MulAssign,
RemAssign,
ShlAssign,
ShrAssign,
);
re_export_traits!("not", not_traits, core::ops, Neg, Not);
re_export_traits!("sum", sum_traits, core::iter, Product, Sum);
re_export_traits!("try_from", try_from_traits, core::convert, TryFrom);
re_export_traits!("try_into", try_into_traits, core::convert, TryInto);
// Now re-export our own derives by their exact name to overwrite any derives that the trait
// re-exporting might inadvertently pull into scope.
#[cfg(feature = "add")]
pub use derive_more_impl::{Add, BitAnd, BitOr, BitXor, Sub};
#[cfg(feature = "add_assign")]
pub use derive_more_impl::{
AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, SubAssign,
};
#[cfg(feature = "as_ref")]
pub use derive_more_impl::{AsMut, AsRef};
#[cfg(feature = "constructor")]
pub use derive_more_impl::Constructor;
#[cfg(feature = "debug")]
pub use derive_more_impl::Debug;
#[cfg(feature = "deref")]
pub use derive_more_impl::Deref;
#[cfg(feature = "deref_mut")]
pub use derive_more_impl::DerefMut;
#[cfg(feature = "display")]
pub use derive_more_impl::{
Binary, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex,
};
#[cfg(feature = "error")]
pub use derive_more_impl::Error;
#[cfg(feature = "from")]
pub use derive_more_impl::From;
#[cfg(feature = "from_str")]
pub use derive_more_impl::FromStr;
#[cfg(feature = "index")]
pub use derive_more_impl::Index;
#[cfg(feature = "index_mut")]
pub use derive_more_impl::IndexMut;
#[cfg(feature = "into")]
pub use derive_more_impl::Into;
#[cfg(feature = "into_iterator")]
pub use derive_more_impl::IntoIterator;
#[cfg(feature = "is_variant")]
pub use derive_more_impl::IsVariant;
#[cfg(feature = "mul")]
pub use derive_more_impl::{Div, Mul, Rem, Shl, Shr};
#[cfg(feature = "mul_assign")]
pub use derive_more_impl::{DivAssign, MulAssign, RemAssign, ShlAssign, ShrAssign};
#[cfg(feature = "not")]
pub use derive_more_impl::{Neg, Not};
#[cfg(feature = "sum")]
pub use derive_more_impl::{Product, Sum};
#[cfg(feature = "try_from")]
pub use derive_more_impl::TryFrom;
#[cfg(feature = "try_into")]
pub use derive_more_impl::TryInto;
#[cfg(feature = "try_unwrap")]
pub use derive_more_impl::TryUnwrap;
#[cfg(feature = "unwrap")]
pub use derive_more_impl::Unwrap;
}
// Now re-export our own derives and the std traits by their exact name to make rust-analyzer
// recognize the #[doc(hidden)] flag.
// See issues:
// 1. https://github.com/rust-lang/rust-analyzer/issues/11698
// 2. https://github.com/rust-lang/rust-analyzer/issues/14079
#[cfg(feature = "add")]
#[doc(hidden)]
pub use all_traits_and_derives::{Add, BitAnd, BitOr, BitXor, Sub};
#[cfg(feature = "add_assign")]
#[doc(hidden)]
pub use all_traits_and_derives::{
AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, SubAssign,
};
#[cfg(feature = "as_ref")]
#[doc(hidden)]
pub use all_traits_and_derives::{AsMut, AsRef};
#[cfg(feature = "constructor")]
#[doc(hidden)]
pub use all_traits_and_derives::Constructor;
#[cfg(feature = "debug")]
#[doc(hidden)]
pub use all_traits_and_derives::Debug;
#[cfg(feature = "deref")]
#[doc(hidden)]
pub use all_traits_and_derives::Deref;
#[cfg(feature = "deref_mut")]
#[doc(hidden)]
pub use all_traits_and_derives::DerefMut;
#[cfg(feature = "display")]
#[doc(hidden)]
pub use all_traits_and_derives::{
Binary, Display, LowerExp, LowerHex, Octal, Pointer, UpperExp, UpperHex,
};
#[cfg(feature = "error")]
#[doc(hidden)]
pub use all_traits_and_derives::Error;
#[cfg(feature = "from")]
#[doc(hidden)]
pub use all_traits_and_derives::From;
#[cfg(feature = "from_str")]
#[doc(hidden)]
pub use all_traits_and_derives::FromStr;
#[cfg(feature = "index")]
#[doc(hidden)]
pub use all_traits_and_derives::Index;
#[cfg(feature = "index_mut")]
#[doc(hidden)]
pub use all_traits_and_derives::IndexMut;
#[cfg(feature = "into")]
#[doc(hidden)]
pub use all_traits_and_derives::Into;
#[cfg(feature = "into_iterator")]
#[doc(hidden)]
pub use all_traits_and_derives::IntoIterator;
#[cfg(feature = "is_variant")]
#[doc(hidden)]
pub use all_traits_and_derives::IsVariant;
#[cfg(feature = "mul")]
#[doc(hidden)]
pub use all_traits_and_derives::{Div, Mul, Rem, Shl, Shr};
#[cfg(feature = "mul_assign")]
#[doc(hidden)]
pub use all_traits_and_derives::{
DivAssign, MulAssign, RemAssign, ShlAssign, ShrAssign,
};
#[cfg(feature = "not")]
#[doc(hidden)]
pub use all_traits_and_derives::{Neg, Not};
#[cfg(feature = "sum")]
#[doc(hidden)]
pub use all_traits_and_derives::{Product, Sum};
#[cfg(feature = "try_from")]
#[doc(hidden)]
pub use all_traits_and_derives::TryFrom;
#[cfg(feature = "try_into")]
#[doc(hidden)]
pub use all_traits_and_derives::TryInto;
#[cfg(feature = "try_unwrap")]
#[doc(hidden)]
pub use all_traits_and_derives::TryUnwrap;
#[cfg(feature = "unwrap")]
#[doc(hidden)]
pub use all_traits_and_derives::Unwrap;
// Re-export the derive macros again to show docs for our derives (but not for traits). This is
// done using a glob import to not hit E0252.
#[allow(unused_imports)]
pub use derive_more_impl::*;
// Check if any feature is enabled
#[cfg(not(any(
feature = "full",
feature = "add",
feature = "add_assign",
feature = "as_ref",
feature = "constructor",
feature = "debug",
feature = "deref",
feature = "deref_mut",
feature = "display",
feature = "error",
feature = "from",
feature = "from_str",
feature = "index",
feature = "index_mut",
feature = "into",
feature = "into_iterator",
feature = "is_variant",
feature = "mul",
feature = "mul_assign",
feature = "not",
feature = "sum",
feature = "try_from",
feature = "try_into",
feature = "try_unwrap",
feature = "unwrap",
)))]
compile_error!(
"at least one derive feature must be enabled (or the \"full\" feature enabling all the derives)"
);

28
vendor/derive_more/src/ops.rs vendored Normal file
View File

@@ -0,0 +1,28 @@
//! Definitions used in derived implementations of [`core::ops`] traits.
use core::fmt;
/// Error returned by the derived implementations when an arithmetic or logic
/// operation is invoked on a unit-like variant of an enum.
#[derive(Clone, Copy, Debug)]
pub struct UnitError {
operation_name: &'static str,
}
impl UnitError {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(operation_name: &'static str) -> Self {
Self { operation_name }
}
}
impl fmt::Display for UnitError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Cannot {}() unit variants", self.operation_name)
}
}
#[cfg(feature = "std")]
impl std::error::Error for UnitError {}

25
vendor/derive_more/src/str.rs vendored Normal file
View File

@@ -0,0 +1,25 @@
use core::fmt;
/// Error of parsing an enum value its string representation.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct FromStrError {
type_name: &'static str,
}
impl FromStrError {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(type_name: &'static str) -> Self {
Self { type_name }
}
}
impl fmt::Display for FromStrError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Invalid `{}` string representation", self.type_name)
}
}
#[cfg(feature = "std")]
impl std::error::Error for FromStrError {}

48
vendor/derive_more/src/try_unwrap.rs vendored Normal file
View File

@@ -0,0 +1,48 @@
/// Error returned by the derived [`TryUnwrap`] implementation.
///
/// [`TryUnwrap`]: macro@crate::TryUnwrap
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct TryUnwrapError<T> {
/// Original input value which failed to convert via the derived
/// [`TryUnwrap`] implementation.
///
/// [`TryUnwrap`]: macro@crate::TryUnwrap
pub input: T,
enum_name: &'static str,
variant_name: &'static str,
func_name: &'static str,
}
impl<T> TryUnwrapError<T> {
#[doc(hidden)]
#[must_use]
#[inline]
pub const fn new(
input: T,
enum_name: &'static str,
variant_name: &'static str,
func_name: &'static str,
) -> Self {
Self {
input,
enum_name,
variant_name,
func_name,
}
}
}
impl<T> core::fmt::Display for TryUnwrapError<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"Attempt to call `{enum_name}::{func_name}()` on a `{enum_name}::{variant_name}` value",
enum_name = self.enum_name,
variant_name = self.variant_name,
func_name = self.func_name,
)
}
}
#[cfg(feature = "std")]
impl<T: core::fmt::Debug> std::error::Error for TryUnwrapError<T> {}

2
vendor/derive_more/src/vendor/mod.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
#[cfg(feature = "error")]
pub mod thiserror;

View File

@@ -0,0 +1,6 @@
# Vendored files from `thiserror`
These are vendored files from the [`thiserror`] crate. The license files in this
directory only apply to the files in this subdirectory of `derive_more`.
[`thiserror`]: https://github.com/dtolnay/thiserror

View File

@@ -0,0 +1,52 @@
#[cfg(not(feature = "std"))]
use core::error::Error;
#[cfg(feature = "std")]
use std::error::Error;
use core::panic::UnwindSafe;
pub trait AsDynError<'a>: Sealed {
fn as_dyn_error(&self) -> &(dyn Error + 'a);
}
impl<'a, T: Error + 'a> AsDynError<'a> for T {
#[inline]
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
self
}
}
impl<'a> AsDynError<'a> for dyn Error + 'a {
#[inline]
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
self
}
}
impl<'a> AsDynError<'a> for dyn Error + Send + 'a {
#[inline]
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
self
}
}
impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a {
#[inline]
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
self
}
}
impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
#[inline]
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
self
}
}
pub trait Sealed {}
impl<'a, T: Error + 'a> Sealed for T {}
impl<'a> Sealed for dyn Error + 'a {}
impl<'a> Sealed for dyn Error + Send + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + 'a {}
impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {}

View File

@@ -0,0 +1 @@
pub mod aserror;