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

File diff suppressed because one or more lines are too long

378
vendor/derive_more/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,378 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.0.1 - Unreleased
## 1.0.0 - 2024-08-07
More than 8 years after the first commit and almost 5 years after the 0.99.0
release, `derive_more` has finally reached its 1.0.0 release. This release
contains a lot of changes (including some breaking ones) to make it easier to
use the derives and make it possible to extend them without having to breaking
backwards compatibility again. There are five major changes that I would like
to call out, but there are many more changes that are documented below:
1. There is a new `Debug` derive that can be used to easily customize `Debug`
formatting.
2. A greatly improved `Display` derive, which allows you to do anything that
[`thiserror`](https://github.com/dtolnay/thiserror) provides, but it works
for any type not just errors. And by combining the `Display` derive with the
`Error` and `From` derives, there shouldn't really be any need to use
`thiserror` anymore (if you are missing a feature/behaviour from `thiserror`
please report an issue).
3. Traits that can return errors now return a type that implements `Error`
when an error occurs instead of a `&'static str`.
4. When using `use derive_more::SomeTrait` the actual trait is also imported
not just the derive macro. This is especially useful for `Error` and
`Display`
5. The docs are now rendered on docs.rs and are much better overall.
### Breaking changes
- The minimum supported Rust version (MSRV) is now Rust 1.75.
- Add the `std` feature which should be disabled in `no_std` environments.
- All Cargo features, except `std`, are now disabled by default. The `full`
feature can be used to get the old behavior of supporting all possible
derives.
- The `TryFrom`, `Add`, `Sub`, `BitAnd`, `BitOr`, `BitXor`, `Not` and `Neg`
derives now return a dedicated error type instead of a `&'static str` on
error.
- The `FromStr` derive now uses a dedicated `FromStrError` error type instead
of generating unique one each time.
- The `Display` derive (and other `fmt`-like ones) now uses
`#[display("...", (<expr>),*)]` syntax instead of
`#[display(fmt = "...", ("<expr>"),*)]`, and `#[display(bound(<bound>))]`
instead of `#[display(bound = "<bound>")]`. So without the double quotes
around the expressions and bounds.
- The `Debug` and `Display` derives (and other `fmt`-like ones) now transparently
delegate to the inner type when `#[display("...", (<expr>),*)]` attribute is
trivially substitutable with a transparent call.
([#322](https://github.com/JelteF/derive_more/pull/322))
- The `DebugCustom` derive is renamed to just `Debug` (gated now under a separate
`debug` feature), and its semantics were changed to be a superset of `std` variant
of `Debug`.
- The `From` derive doesn't derive `From<()>` for enum variants without any
fields anymore. This feature was removed because it was considered useless in
practice.
- The `From` derive now uses `#[from(<types>)]` instead of `#[from(types(<types>))]`
and ignores field type itself.
- The `Into` derive now uses `#[into(<types>)]` instead of `#[into(types(<types>))]`
and ignores field type itself.
- The `Into` derive now generates separate impls for each field whenever the `#[into(...)]`
attribute is applied to it. ([#291](https://github.com/JelteF/derive_more/pull/291))
- Importing a derive macro now also imports its corresponding trait.
- The `Error` derive is updated with changes to the `error_generic_member_access`
unstable feature for nightly users. ([#200](https://github.com/JelteF/derive_more/pull/200),
[#294](https://github.com/JelteF/derive_more/pull/294))
- The `as_mut` feature is removed, and the `AsMut` derive is now gated by the
`as_ref` feature. ([#295](https://github.com/JelteF/derive_more/pull/295))
- A top level `#[display("...")]` attribute on an enum now requires the usage
of `{_variant}` to include the variant instead of including it at `{}`. The
reason is that `{}` now references the first argument to the format string,
just like in all other format strings. ([#377](https://github.com/JelteF/derive_more/pull/377))
### Added
- Add support captured identifiers in `Display` derives. So now you can use:
`#[display(fmt = "Prefix: {field}")]` instead of needing to use
`#[display(fmt = "Prefix: {}", field)]`
- Add `FromStr` derive support for enums that contain variants without fields.
If you pass the name of the variant to `from_str` it will create the matching
variant.
- Add `#[unwrap(owned, ref, ref_mut)]` attribute for the `Unwrap` derive.
By using them, it is possible to derive implementations for the reference types as well.
([#206](https://github.com/JelteF/derive_more/pull/206))
- Add `TryUnwrap` derive similar to the `Unwrap` derive. This one returns a `Result` and does not panic.
([#206](https://github.com/JelteF/derive_more/pull/206))
- Add support for container format in `Debug` derive with the same syntax as `Display` derives.
([#279](https://github.com/JelteF/derive_more/pull/279))
- `derive_more::derive` module exporting only macros, without traits.
([#290](https://github.com/JelteF/derive_more/pull/290))
- Add support for specifying concrete types to `AsRef`/`AsMut` derives.
([#298](https://github.com/JelteF/derive_more/pull/298))
- Add `TryFrom` derive for enums to convert from their discriminant.
([#300](https://github.com/JelteF/derive_more/pull/300))
- `#[inline]` attributes to `IsVariant` and `Debug` implementations.
([#334](https://github.com/JelteF/derive_more/pull/334)
- Add `#[track_caller]` to `Add`, `Mul`, `AddAssign` and `MulAssign` derives
([#378](https://github.com/JelteF/derive_more/pull/378)
### Changed
- The `Constructor` and `IsVariant` derives now generate `const fn` functions.
- Static methods derived by `IsVariant` are now marked `#[must_use]`.
([#350](https://github.com/JelteF/derive_more/pull/350))
- The `Unwrap` and `IsVariant` derives now generate doc comments.
- `#[automatically_derived]` is now emitted from all macro expansions. This
should prevent code style linters from attempting to modify the generated
code.
- Upgrade to `syn` 2.0.
- The `Error` derive now works in nightly `no_std` environments
### Fixed
- Use a deterministic `HashSet` in all derives, this is needed for rust analyzer
to work correctly.
- Use `Provider` API for backtraces in `Error` derive.
- Fix `Error` derive not working with `const` generics.
- Support trait objects for source in Error, e.g.
`Box<dyn Error + Send + 'static>`
- Fix bounds on derived `IntoIterator` impls for generic structs.
([#284](https://github.com/JelteF/derive_more/pull/284))
- Fix documentation of generated bounds in `Display` derive.
([#297](https://github.com/JelteF/derive_more/pull/297))
- Hygiene of macro expansions in presence of custom `core` crate.
([#327](https://github.com/JelteF/derive_more/pull/327))
- Fix documentation of generated methods in `IsVariant` derive.
- Make `{field:p}` do the expected thing in format strings for `Display` and
`Debug`. Also document weirdness around `Pointer` formatting when using
expressions, due to field variables being references.
([#381](https://github.com/JelteF/derive_more/pull/381))
## 0.99.10 - 2020-09-11
### Added
- `From` supports additional types for conversion: `#[from(types(u8, u16))]`.
## 0.99.7 - 2020-05-16
### Changed
- When specifying specific features of the crate to only enable specific
derives, the `extra-traits` feature of `syn` is not always enabled
when those the specified features do not require it. This should speed up
compile time of `syn` when this feature is not needed.
### Fixed
- Fix generic derives for `MulAssign`
## 0.99.6 - 2020-05-13
### Changed
- Make sure output of derives is deterministic, for better support in
rust-analyzer
## 0.99.5 - 2020-03-28
### Added
- Support for deriving `Error`!!! (many thanks to @ffuugoo and @tyranron)
### Fixed
- Fix generic bounds for `Deref` and `DerefMut` with `forward`, i.e. put `Deref`
bound on whole type, so on `where Box<T>: Deref` instead of on `T: Deref`.
([#107](https://github.com/JelteF/derive_more/issues/114))
- The `tests` directory is now correctly included in the crate (requested by
Debian package maintainers)
## 0.99.4 - 2020-03-28 [YANKED]
Note: This version is yanked, because quickly after release it was found out
tests did not run in CI.
## 0.99.3 - 2020-02-19
### Fixed
- Fix generic bounds for `Deref` and `DerefMut` with no `forward`, i.e. no bounds
are necessary. ([#107](https://github.com/JelteF/derive_more/issues/114))
## 0.99.2 - 2019-11-17
### Fixed
- Hotfix for a regression in allowed `Display` derives using `#` flag, such as
`{:#b}` ([#107](https://github.com/JelteF/derive_more/issues/107))
## 0.99.1 - 2019-11-12
### Fixed
- Hotfix for a regression in allowed `From` derives
([#105](https://github.com/JelteF/derive_more/issues/105))
## 0.99.0 - 2019-11-11
This release is a huge milestone for this library.
Lot's of new derives are implemented and a ton of attributes are added for
configuration purposes.
These attributes will allow future releases to add features/options without
breaking backwards compatibility.
This is why the next release with breaking changes is planned to be 1.0.0.
### Breaking changes
- The minimum supported rust version (MSRV) is now Rust 1.36.
- When using in a Rust 2015 crate, you should add `extern crate core` to your
code.
- `no_std` feature is removed, the library now supports `no_std` without having
to configure any features.
### Added
- `Deref` derives now dereference to the type in the newtype. So if you have
`MyBox(Box<i32>)`, dereferencing it will result in a `Box<i32>` not an `i32`.
To get the old behaviour of forwarding the dereference you can add the
`#[deref(forward)]` attribute on the struct or field.
- Derives for `AsRef`, `AsMut`, `Sum`, `Product`, `IntoIterator`.
- Choosing the field of a struct for which to derive the newtype derive.
- Ignoring variants of enums when deriving `From`, by using `#[from(ignore)]`.
- Add `#[from(forward)]` attribute for `From` derives. This forwards the `from`
calls to the fields themselves. So if your field is an `i64` you can call from
on an `i32` and it will work.
- Add `#[mul(forward)]` and `#[mul_assign(forward)]`, which implement `Mul` and
`MulAssign` with the semantics as if they were `Add`/`AddAssign`.
- You can use features to cut down compile time of the crate by only compiling
the code needed for the derives that you use. (see Cargo.toml for the
features, by default they are all on)
- Add `#[into(owned, ref, ref_mut)]` and `#[try_into(owned, ref, ref_mut)]`
attributes. These cause the `Into` and `TryInto` derives to also implement
derives that return references to the inner fields.
- Allow `#[display(fmt="some shared display text for all enum variants {}")]`
attribute on enum.
- Better bounds inference of `Display` trait.
### Changed
- Remove dependency on `regex` to cut down compile time.
- Use `syn` 1.0
## 0.15.0 - 2019-06-08
### Fixed
- Automatic detection of traits needed for `Display` format strings
## 0.14.0 - 2019-02-02
### Added
- Added `no_std` support
### Changed
- Suppress `unused_variables` warnings in derives
## 0.13.0 - 2018-10-19
### Added
- Extended Display-like derives to support custom formats
### Changed
- Updated to `syn` v0.15
## 0.12.0 - 2018-09-19
### Changed
- Updated to `syn` v0.14, `quote` v0.6 and `proc-macro2` v0.4
## 0.11.0 - 2018-05-12
### Changed
- Updated to latest version of `syn` and `quote`
### Fixed
- Changed some URLs in the docs so they were correct on crates.io and docs.rs
- The `Result` type is now referenced in the derives using its absolute path
(`::std::result::Result`) to make sure that the derives don't accidentally use
another `Result` type that is in scope.
## 0.10.0 - 2018-03-29
### Added
- Allow deriving of `TryInto`
- Allow deriving of `Deref`
- Allow deriving of `DerefMut`
## 0.9.0 - 2018-03-18
### Added
- Allow deriving of `Display`, `Binary`, `Octal`, `LowerHex`, `UpperHex`, `LowerExp`, `UpperExp`, `Pointer`
- Allow deriving of `Index`
- Allow deriving of `IndexMut`
### Fixed
- Allow cross crate inlining of derived methods
## 0.8.0 - 2018-03-10
### Added
- Allow deriving of `FromStr`
### Changed
- Updated to latest version of `syn` and `quote`
## 0.7.1 - 2018-01-25
### Fixed
- Add `#[allow(missing_docs)]` to the Constructor definition
## 0.7.0 - 2017-07-25
### Changed
- Changed code to work with newer version of the `syn` library.
## 0.6.2 - 2017-04-23
### Changed
- Deriving `From`, `Into` and `Constructor` now works for empty structs.
## 0.6.1 - 2017-03-08
### Changed
- The `new()` method that is created when deriving `Constructor` is now public.
This makes it a lot more useful.
## 0.6.0 - 2017-02-20
### Added
- Derives for `Into`, `Constructor` and `MulAssign`-like
### Changed
- `From` is now derived for enum variants with multiple fields.
### Fixed
- Derivations now support generics.
## 0.5.0 - 2017-02-02
### Added
- Lots of docs.
- Derives for `Neg`-like and `AddAssign`-like.
### Changed
- `From` can now be derived for structs with multiple fields.

345
vendor/derive_more/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,345 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "derive_more"
version = "1.0.0"
dependencies = [
"derive_more-impl",
"rustc_version",
"rustversion",
"static_assertions",
"trybuild",
]
[[package]]
name = "derive_more-impl"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn",
"unicode-xid",
]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "indexmap"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "itoa"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "proc-macro2"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "rustversion"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
[[package]]
name = "ryu"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "semver"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "2.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "toml"
version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.22.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
name = "trybuild"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b1e5645f2ee8025c2f1d75e1138f2dd034d74e6ba54620f3c569ba2a2a1ea06"
dependencies = [
"glob",
"serde",
"serde_derive",
"serde_json",
"termcolor",
"toml",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-segmentation"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "unicode-xid"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "winapi-util"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f"
dependencies = [
"memchr",
]

309
vendor/derive_more/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,309 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.75.0"
name = "derive_more"
version = "1.0.0"
authors = ["Jelte Fennema <github-tech@jeltef.nl>"]
build = false
include = [
"src/**/*.rs",
"Cargo.toml",
"LICENSE",
"README.md",
"CHANGELOG.md",
"tests/**/*.rs",
"examples/**/*.rs",
]
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Adds #[derive(x)] macros for more traits"
documentation = "https://docs.rs/derive_more"
readme = "README.md"
keywords = [
"derive",
"Add",
"From",
"Display",
"IntoIterator",
]
categories = [
"development-tools",
"development-tools::procedural-macro-helpers",
"no-std",
"rust-patterns",
]
license = "MIT"
repository = "https://github.com/JelteF/derive_more"
[package.metadata.docs.rs]
features = ["full"]
rustdoc-args = [
"--cfg",
"docsrs",
]
[lib]
name = "derive_more"
path = "src/lib.rs"
[[example]]
name = "deny_missing_docs"
path = "examples/deny_missing_docs.rs"
required-features = ["full"]
[[test]]
name = "add"
path = "tests/add.rs"
required-features = ["add"]
[[test]]
name = "add_assign"
path = "tests/add_assign.rs"
required-features = ["add_assign"]
[[test]]
name = "as_mut"
path = "tests/as_mut.rs"
required-features = ["as_ref"]
[[test]]
name = "as_ref"
path = "tests/as_ref.rs"
required-features = ["as_ref"]
[[test]]
name = "boats_display_derive"
path = "tests/boats_display_derive.rs"
required-features = ["display"]
[[test]]
name = "compile_fail"
path = "tests/compile_fail/mod.rs"
required-features = [
"as_ref",
"debug",
"display",
"from",
"into",
"is_variant",
"try_from",
]
[[test]]
name = "constructor"
path = "tests/constructor.rs"
required-features = ["constructor"]
[[test]]
name = "debug"
path = "tests/debug.rs"
required-features = ["debug"]
[[test]]
name = "deref"
path = "tests/deref.rs"
required-features = ["deref"]
[[test]]
name = "deref_mut"
path = "tests/deref_mut.rs"
required-features = ["deref_mut"]
[[test]]
name = "display"
path = "tests/display.rs"
required-features = ["display"]
[[test]]
name = "error"
path = "tests/error_tests.rs"
required-features = ["error"]
[[test]]
name = "from"
path = "tests/from.rs"
required-features = ["from"]
[[test]]
name = "from_str"
path = "tests/from_str.rs"
required-features = ["from_str"]
[[test]]
name = "generics"
path = "tests/generics.rs"
required-features = ["full"]
[[test]]
name = "index"
path = "tests/index.rs"
required-features = ["index"]
[[test]]
name = "index_mut"
path = "tests/index_mut.rs"
required-features = ["index_mut"]
[[test]]
name = "into"
path = "tests/into.rs"
required-features = ["into"]
[[test]]
name = "into_iterator"
path = "tests/into_iterator.rs"
required-features = ["into_iterator"]
[[test]]
name = "is_variant"
path = "tests/is_variant.rs"
required-features = ["is_variant"]
[[test]]
name = "lib"
path = "tests/lib.rs"
required-features = ["full"]
[[test]]
name = "mul"
path = "tests/mul.rs"
required-features = ["mul"]
[[test]]
name = "mul_assign"
path = "tests/mul_assign.rs"
required-features = ["mul_assign"]
[[test]]
name = "no_std"
path = "tests/no_std.rs"
required-features = ["full"]
[[test]]
name = "not"
path = "tests/not.rs"
required-features = ["not"]
[[test]]
name = "sum"
path = "tests/sum.rs"
required-features = ["sum"]
[[test]]
name = "try_from"
path = "tests/try_from.rs"
required-features = ["try_from"]
[[test]]
name = "try_into"
path = "tests/try_into.rs"
required-features = ["try_into"]
[[test]]
name = "try_unwrap"
path = "tests/try_unwrap.rs"
required-features = ["try_unwrap"]
[[test]]
name = "unwrap"
path = "tests/unwrap.rs"
required-features = ["unwrap"]
[dependencies.derive_more-impl]
version = "=1.0.0"
[dev-dependencies.rustversion]
version = "1.0"
[dev-dependencies.static_assertions]
version = "1.1"
[dev-dependencies.trybuild]
version = "1.0.56"
[build-dependencies.rustc_version]
version = "0.4"
optional = true
[features]
add = ["derive_more-impl/add"]
add_assign = ["derive_more-impl/add_assign"]
as_ref = ["derive_more-impl/as_ref"]
constructor = ["derive_more-impl/constructor"]
debug = ["derive_more-impl/debug"]
default = ["std"]
deref = ["derive_more-impl/deref"]
deref_mut = ["derive_more-impl/deref_mut"]
display = ["derive_more-impl/display"]
error = ["derive_more-impl/error"]
from = ["derive_more-impl/from"]
from_str = ["derive_more-impl/from_str"]
full = [
"add",
"add_assign",
"as_ref",
"constructor",
"debug",
"deref",
"deref_mut",
"display",
"error",
"from",
"from_str",
"index",
"index_mut",
"into",
"into_iterator",
"is_variant",
"mul",
"mul_assign",
"not",
"sum",
"try_from",
"try_into",
"try_unwrap",
"unwrap",
]
index = ["derive_more-impl/index"]
index_mut = ["derive_more-impl/index_mut"]
into = ["derive_more-impl/into"]
into_iterator = ["derive_more-impl/into_iterator"]
is_variant = ["derive_more-impl/is_variant"]
mul = ["derive_more-impl/mul"]
mul_assign = ["derive_more-impl/mul_assign"]
not = ["derive_more-impl/not"]
std = []
sum = ["derive_more-impl/sum"]
testing-helpers = [
"derive_more-impl/testing-helpers",
"dep:rustc_version",
]
try_from = ["derive_more-impl/try_from"]
try_into = ["derive_more-impl/try_into"]
try_unwrap = ["derive_more-impl/try_unwrap"]
unwrap = ["derive_more-impl/unwrap"]
[badges.github]
repository = "JelteF/derive_more"
workflow = "CI"
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = [
"cfg(ci)",
"cfg(nightly)",
]

21
vendor/derive_more/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Jelte Fennema
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

271
vendor/derive_more/README.md vendored Normal file
View File

@@ -0,0 +1,271 @@
# `derive_more`
[![Build Status](https://github.com/JelteF/derive_more/workflows/CI/badge.svg)](https://github.com/JelteF/derive_more/actions)
[![Latest Version](https://img.shields.io/crates/v/derive_more.svg)](https://crates.io/crates/derive_more)
[![Rust Documentation](https://docs.rs/derive_more/badge.svg)](https://docs.rs/derive_more)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/JelteF/derive_more/master/LICENSE)
[![Rust 1.75+](https://img.shields.io/badge/rustc-1.75+-lightgray.svg)](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)
Rust has lots of builtin traits that are implemented for its basic types, such
as `Add`, `Not`, `From` or `Display`.
However, when wrapping these types inside your own structs or enums you lose the
implementations of these traits and are required to recreate them.
This is especially annoying when your own structures are very simple, such as
when using the commonly advised newtype pattern (e.g. `MyInt(i32)`).
This library tries to remove these annoyances and the corresponding boilerplate code.
It does this by allowing you to derive lots of commonly used traits for both structs and enums.
## Example code
By using this library the following code just works:
```rust
use derive_more::{Add, Display, From, Into};
#[derive(PartialEq, From, Add)]
struct MyInt(i32);
#[derive(PartialEq, From, Into)]
struct Point2D {
x: i32,
y: i32,
}
#[derive(PartialEq, From, Add, Display)]
enum MyEnum {
#[display("int: {_0}")]
Int(i32),
Uint(u32),
#[display("nothing")]
Nothing,
}
assert!(MyInt(11) == MyInt(5) + 6.into());
assert!((5, 6) == Point2D { x: 5, y: 6 }.into());
assert!(MyEnum::Int(15) == (MyEnum::Int(8) + 7.into()).unwrap());
assert!(MyEnum::Int(15).to_string() == "int: 15");
assert!(MyEnum::Uint(42).to_string() == "42");
assert!(MyEnum::Nothing.to_string() == "nothing");
```
## The derivable traits
Below are all the traits that you can derive using this library.
Some trait derivations are so similar that the further documentation will only show a single one
of them.
You can recognize these by the "-like" suffix in their name.
The trait name before that will be the only one that is used throughout the further
documentation.
It is important to understand what code gets generated when using one of the
derives from this crate.
That is why the links below explain what code gets generated for a trait for
each group from before.
You can use the [`cargo-expand`] utility to see the exact code that is generated
for your specific type.
This will show you your code with all macros and derives expanded.
**NOTE**: You still have to derive each trait separately. So `#[derive(Mul)]` doesn't
automatically derive `Div` as well. To derive both you should do `#[derive(Mul, Div)]`
### Conversion traits
These are traits that are used to convert automatically between types.
1. [`From`]
2. [`Into`]
3. [`FromStr`]
4. [`TryFrom`]
5. [`TryInto`]
6. [`IntoIterator`]
7. [`AsRef`], [`AsMut`]
### Formatting traits
These traits are used for converting a struct to a string in different ways.
1. [`Debug`]
2. [`Display`-like], contains `Display`, `Binary`, `Octal`, `LowerHex`,
`UpperHex`, `LowerExp`, `UpperExp`, `Pointer`
### Error-handling traits
These traits are used to define error-types.
1. [`Error`]
### Operators
These are traits that can be used for operator overloading.
1. [`Index`]
2. [`Deref`]
3. [`Not`-like], contains `Not` and `Neg`
4. [`Add`-like], contains `Add`, `Sub`, `BitAnd`, `BitOr`, `BitXor`
5. [`Mul`-like], contains `Mul`, `Div`, `Rem`, `Shr` and `Shl`
6. [`Sum`-like], contains `Sum` and `Product`
7. [`IndexMut`]
8. [`DerefMut`]
9. [`AddAssign`-like], contains `AddAssign`, `SubAssign`, `BitAndAssign`,
`BitOrAssign` and `BitXorAssign`
10. [`MulAssign`-like], contains `MulAssign`, `DivAssign`, `RemAssign`,
`ShrAssign` and `ShlAssign`
### Static methods
These don't derive traits, but derive static methods instead.
1. [`Constructor`], this derives a `new` method that can be used as a constructor.
This is very basic if you need more customization for your constructor, check
out the [`derive-new`] crate.
2. [`IsVariant`], for each variant `foo` of an enum type, derives a `is_foo` method.
3. [`Unwrap`], for each variant `foo` of an enum type, derives an `unwrap_foo` method.
4. [`TryUnwrap`], for each variant `foo` of an enum type, derives an `try_unwrap_foo` method.
### Re-exports
This crate also re-exports all the standard library traits that it adds derives
for. So, both the `Display` derive and the `Display` trait will be in scope when
you add the following code:
```rust
use derive_more::Display; // also imports `core::fmt::Display`
```
For derive macros only, without the corresponding traits, do import them from
the `derive` module:
```rust
use derive_more::derive::Display; // imports macro only
```
#### Hygiene
For hygiene purposes, macros use `derive_more::*` absolute paths in their expansions.
This might introduce a trouble, if you want to re-export `derive_more` macros in your
own crate without using the `derive_more` as a direct dependency in downstream crates:
```rust,ignore
use my_lib::Display; // re-exported in `my_lib` crate
#[derive(Display)] // error: could not find `derive_more` in the list of imported crates
struct MyInt(i32);
```
In such case, you should re-export the `derive_more` module too:
```rust,ignore
use my_lib::{derive_more, Display}; // re-exported in `my_lib` crate
#[derive(Display)] // works fine now!
struct MyInt(i32);
```
## Installation
To avoid redundant compilation times, by default no derives are supported.
You have to enable each type of derive as a feature in `Cargo.toml`:
```toml
[dependencies]
# You can specify the types of derives that you need for less time spent
# compiling. For the full list of features see this crate its `Cargo.toml`.
derive_more = { version = "1", features = ["from", "add", "iterator"] }
```
```toml
[dependencies]
# If you don't care much about compilation times and simply want to have
# support for all the possible derives, you can use the "full" feature.
derive_more = { version = "1", features = ["full"] }
```
```toml
[dependencies]
# If you run in a `no_std` environment you should disable the default features,
# because the only default feature is the "std" feature.
# NOTE: You can combine this with "full" feature to get support for all the
# possible derives in a `no_std` environment.
derive_more = { version = "1", default-features = false }
```
And this to the top of your Rust file:
```rust
// use the derives that you want in the file
use derive_more::{Add, Display, From};
```
If you're still using Rust 2015, add this instead:
```rust,edition2015
extern crate core;
#[macro_use]
extern crate derive_more;
# fn main() {} // omit wrapping statements above into `main()` in tests
```
## [MSRV] policy
This library requires Rust 1.75 or higher.
Changing [MSRV] (minimum supported Rust version) of this crate is treated as a **minor version change** in terms of [Semantic Versioning].
- So, if [MSRV] changes are **NOT concerning** for your project, just use the default [caret requirement]:
```toml
[dependencies]
derive_more = "1" # or "1.0", or "^1.0"
```
- However, if [MSRV] changes are concerning for your project, then use the [tilde requirement] to **pin to a specific minor version**:
```toml
[dependencies]
derive_more = "~1.0" # or "~1.0.0"
```
[`cargo-expand`]: https://github.com/dtolnay/cargo-expand
[`derive-new`]: https://github.com/nrc/derive-new
[`From`]: https://docs.rs/derive_more/latest/derive_more/derive.From.html
[`Into`]: https://docs.rs/derive_more/latest/derive_more/derive.Into.html
[`FromStr`]: https://docs.rs/derive_more/latest/derive_more/derive.FromStr.html
[`TryFrom`]: https://docs.rs/derive_more/latest/derive_more/derive.TryFrom.html
[`TryInto`]: https://docs.rs/derive_more/latest/derive_more/derive.TryInto.html
[`IntoIterator`]: https://docs.rs/derive_more/latest/derive_more/derive.IntoIterator.html
[`AsRef`]: https://docs.rs/derive_more/latest/derive_more/derive.AsRef.html
[`AsMut`]: https://docs.rs/derive_more/latest/derive_more/derive.AsMut.html
[`Debug`]: https://docs.rs/derive_more/latest/derive_more/derive.Debug.html
[`Display`-like]: https://docs.rs/derive_more/latest/derive_more/derive.Display.html
[`Error`]: https://docs.rs/derive_more/latest/derive_more/derive.Error.html
[`Index`]: https://docs.rs/derive_more/latest/derive_more/derive.Index.html
[`Deref`]: https://docs.rs/derive_more/latest/derive_more/derive.Deref.html
[`Not`-like]: https://docs.rs/derive_more/latest/derive_more/derive.Not.html
[`Add`-like]: https://docs.rs/derive_more/latest/derive_more/derive.Add.html
[`Mul`-like]: https://docs.rs/derive_more/latest/derive_more/derive.Mul.html
[`Sum`-like]: https://docs.rs/derive_more/latest/derive_more/derive.Sum.html
[`IndexMut`]: https://docs.rs/derive_more/latest/derive_more/derive.IndexMut.html
[`DerefMut`]: https://docs.rs/derive_more/latest/derive_more/derive.DerefMut.html
[`AddAssign`-like]: https://docs.rs/derive_more/latest/derive_more/derive.AddAssign.html
[`MulAssign`-like]: https://docs.rs/derive_more/latest/derive_more/derive.MulAssign.html
[`Constructor`]: https://docs.rs/derive_more/latest/derive_more/derive.Constructor.html
[`IsVariant`]: https://docs.rs/derive_more/latest/derive_more/derive.IsVariant.html
[`Unwrap`]: https://docs.rs/derive_more/latest/derive_more/derive.Unwrap.html
[`TryUnwrap`]: https://docs.rs/derive_more/latest/derive_more/derive.TryUnwrap.html
[caret requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements
[tilde requirement]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning]: http://semver.org

View File

@@ -0,0 +1,42 @@
//! Some docs
#![deny(missing_docs)]
#![allow(dead_code)] // for illustration purposes
use derive_more::{
Add, AddAssign, Constructor, Deref, DerefMut, Display, From, FromStr, Index,
IndexMut, Into, IsVariant, Mul, MulAssign, Not, TryInto,
};
fn main() {}
/// Some docs
#[derive(
Add,
AddAssign,
Constructor,
Display,
From,
FromStr,
Into,
Mul,
MulAssign,
Not
)]
pub struct MyInt(i32);
/// Some docs
#[derive(Deref, DerefMut)]
pub struct MyBoxedInt(Box<i32>);
/// Some docs
#[derive(Index, IndexMut)]
pub struct MyVec(Vec<i32>);
/// Some docs
#[derive(Clone, Copy, TryInto)]
#[derive(IsVariant)]
enum MixedInts {
SmallInt(i32),
NamedBigInt { int: i64 },
}

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;

24
vendor/derive_more/tests/add.rs vendored Normal file
View File

@@ -0,0 +1,24 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)] // some code is tested for type checking only
use derive_more::Add;
#[derive(Add)]
struct MyInts(i32, i32);
#[derive(Add)]
struct Point2D {
x: i32,
y: i32,
}
#[derive(Add)]
enum MixedInts {
SmallInt(i32),
BigInt(i64),
TwoSmallInts(i32, i32),
NamedSmallInts { x: i32, y: i32 },
UnsignedOne(u32),
UnsignedTwo(u32),
Unit,
}

13
vendor/derive_more/tests/add_assign.rs vendored Normal file
View File

@@ -0,0 +1,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)] // some code is tested for type checking only
use derive_more::AddAssign;
#[derive(AddAssign)]
struct MyInts(i32, i32);
#[derive(AddAssign)]
struct Point2D {
x: i32,
y: i32,
}

1350
vendor/derive_more/tests/as_mut.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1343
vendor/derive_more/tests/as_ref.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
// The following code is from https://github.com/withoutboats/display_derive/blob/232a32ee19e262aacbd2c93be5b4ce9e89a5fc30/tests/tests.rs
// Written by without boats originally
use derive_more::Display;
#[derive(Display)]
#[display("An error has occurred.")]
struct UnitError;
#[test]
fn unit_struct() {
let s = UnitError.to_string();
assert_eq!(s, "An error has occurred.");
}
#[derive(Display)]
#[display("Error code: {}", code)]
struct RecordError {
code: u32,
}
#[test]
fn record_struct() {
let s = RecordError { code: 0 }.to_string();
assert_eq!(s, "Error code: 0");
}
#[derive(Display)]
#[display("Error code: {}", _0)]
struct TupleError(i32);
#[test]
fn tuple_struct() {
let s = TupleError(2).to_string();
assert_eq!(s, "Error code: 2");
}
#[allow(clippy::enum_variant_names)] // because of the original source
#[derive(Display)]
enum EnumError {
#[display("Error code: {}", code)]
StructVariant { code: i32 },
#[display("Error: {}", _0)]
TupleVariant(&'static str),
#[display("An error has occurred.")]
UnitVariant,
}
#[test]
fn enum_error() {
let s = EnumError::StructVariant { code: 2 }.to_string();
assert_eq!(s, "Error code: 2");
let s = EnumError::TupleVariant("foobar").to_string();
assert_eq!(s, "Error: foobar");
let s = EnumError::UnitVariant.to_string();
assert_eq!(s, "An error has occurred.");
}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsMut)]
enum Foo {
Bar(i32),
Baz(i32),
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsMut)]
struct Foo {
#[as_mut]
#[as_mut(forward)]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsMut)]
#[as_mut(forward)]
#[as_mut(forward)]
struct Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,12 @@
struct Foo<T>(T);
type Bar<T> = Foo<T>;
#[derive(derive_more::AsMut)]
#[as_mut(Bar<T>)]
struct Baz<T>(Foo<T>);
fn main() {
let mut item = Baz(Foo(1i32));
let _: &mut Bar<i32> = item.as_mut();
}

View File

@@ -0,0 +1,9 @@
#[derive(derive_more::AsMut)]
struct Foo {
#[as_mut]
bar: i32,
#[as_mut(ignore)]
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsMut)]
#[as_mut(forward)]
struct Foo {
#[as_mut]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::AsMut)]
#[as_mut(forward)]
struct Foo;
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsMut)]
#[as_mut(forward)]
struct Foo {
bar: i32,
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsMut)]
#[as_mut((i32, f32))]
struct Foo {
bar: i32,
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsMut)]
union Foo {
f1: u32,
f2: f32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsMut)]
struct Foo {
#[as_mut(baz)]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsMut)]
#[as_mut(baz)]
struct Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsRef)]
enum Foo {
Bar(i32),
Baz(i32),
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsRef)]
struct Foo {
#[as_ref]
#[as_ref(forward)]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsRef)]
#[as_ref(forward)]
#[as_ref(forward)]
struct Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,12 @@
struct Foo<T>(T);
type Bar<T> = Foo<T>;
#[derive(derive_more::AsRef)]
#[as_ref(Bar<T>)]
struct Baz<T>(Foo<T>);
fn main() {
let item = Baz(Foo(1i32));
let _: &Bar<i32> = item.as_ref();
}

View File

@@ -0,0 +1,9 @@
#[derive(derive_more::AsRef)]
struct Foo {
#[as_ref]
bar: i32,
#[as_ref(skip)]
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsRef)]
#[as_ref(forward)]
struct Foo {
#[as_ref]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::AsRef)]
#[as_ref(forward)]
struct Foo;
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsRef)]
#[as_ref(forward)]
struct Foo {
bar: i32,
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::AsRef)]
#[as_ref((i32, f32))]
struct Foo {
bar: i32,
baz: f32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsRef)]
union Foo {
f1: u32,
f2: f32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsRef)]
struct Foo {
#[as_ref(baz)]
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::AsRef)]
#[as_ref(baz)]
struct Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({}): {}", bar)]
#[debug(skip)]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::Debug)]
#[debug("Test")]
#[debug("Second")]
pub struct Foo {}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Debug)]
pub enum Foo {
#[debug("Test")]
#[debug("Second")]
Unit,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({}): {}", bar)]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Debug)]
#[debug("{bar}")]
pub struct Foo {
#[debug("{bar}")]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
#[debug("Test")]
pub enum Foo {
Unit
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
#[debug(bound = "String: std::fmt::Display")]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,11 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug(fmt = "Stuff({}): {}", "bar")]
bar: String,
}
#[derive(derive_more::Debug)]
#[debug(fmt = "Stuff({}): {}", _0)]
pub struct Bar(String);
fn main() {}

View File

@@ -0,0 +1,10 @@
struct NoDebug<'a> {
a: &'a f64,
}
#[derive(derive_more::Debug)]
struct SomeType<'a> {
no_debug: NoDebug<'a>,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff()", bar)]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({})", .bar)]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({)", bar)]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::Debug)]
pub union Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
#[debug(unknown = "unknown")]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,4 @@
#[derive(derive_more::Debug)]
pub struct Foo(#[debug("Stuff({})", .0)] String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({bar:M})")]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Debug)]
pub struct Foo {
#[debug("Stuff({bars})")]
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,4 @@
#[derive(derive_more::Debug)]
pub struct Foo(#[debug("Stuff({_1})")] String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({}): {}", bar)]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display(bound = "String: std::fmt::Display")]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,11 @@
#[derive(derive_more::Display)]
#[display(fmt = "Stuff({}): {}", "bar")]
pub struct Foo {
bar: String,
}
#[derive(derive_more::Display)]
#[display(fmt = "Stuff({}): {}", _0)]
pub struct Bar(String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff()", bar)]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::Display)]
enum Enum {
Variant { foo: String, bar: String },
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
pub struct Foo {
foo: String,
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({})", .bar)]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::Display, derive_more::UpperHex)]
enum Enum {
UnitVariant,
}
fn main() {}

View File

@@ -0,0 +1,19 @@
#[derive(derive_more::Display)]
#[display("Stuff({})")]
enum Foo {
A,
}
#[derive(derive_more::Display)]
#[display("Stuff({0})")]
enum Foo2 {
A,
}
#[derive(derive_more::Display)]
#[display("Stuff()", _0, _2)]
enum Foo3 {
A,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({)")]
enum Foo {
A,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({_variant:?})")]
enum Foo {
A,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({)", bar)]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Display)]
#[display("Stuff({})", bar)]
#[display(unknown = "unknown")]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::Display)]
#[display("Stuff({})", .0)]
pub struct Foo(String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({:M})", bar)]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Display)]
#[display("Stuff({bars})")]
pub struct Foo {
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::Display)]
#[display("Stuff({_1})")]
pub struct Foo(String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::From)]
enum Foo {
#[from(types(i32, "&str"))]
Bar(String),
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::From)]
#[from(types(i32, "&str"))]
struct Foo {
foo: String,
bar: String,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::From)]
enum Foo {
#[from(i32)]
#[from(forward)]
Bar(i32),
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::From)]
#[from(i32)]
#[from(forward)]
struct Foo(i32);
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::From)]
#[from(i16, i16)]
struct Point {
x: i32,
y: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::From)]
#[from((i16, i16, i16))]
struct Point {
x: i32,
y: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::From)]
#[from((i16,))]
struct Point {
x: i32,
y: i32,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::From)]
pub union Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,6 @@
#[derive(derive_more::Into)]
enum Foo {
Foo(i32),
}
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::Into)]
#[into(owned(types("Cow<'_ str>")), ref, ref_mut, types(i32, "&str"))]
struct Foo(String);
fn main() {}

View File

@@ -0,0 +1,5 @@
#[derive(derive_more::Into)]
#[into(types(i32, "&str"))]
struct Foo(String);
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Into)]
struct Foo {
#[into(skip, i32)]
a: i32,
}
fn main() {}

View File

@@ -0,0 +1,7 @@
#[derive(derive_more::Into)]
#[into(owned, ref(i32), i32)]
struct Foo {
bar: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Into)]
struct Foo {
#[into(skip)]
#[into(skip)]
a: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Into)]
#[into(i16, i16)]
struct Point {
x: i32,
y: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Into)]
#[into((i16, i16, i16))]
struct Point {
x: i32,
y: i32,
}
fn main() {}

View File

@@ -0,0 +1,8 @@
#[derive(derive_more::Into)]
#[into((i16,))]
struct Point {
x: i32,
y: i32,
}
fn main() {}

Some files were not shown because too many files have changed in this diff Show More