diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
commit | ef24de24a82fe681581cc130f342363c47c0969a (patch) | |
tree | 0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/derivative/doc | |
parent | Releasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/derivative/doc')
-rw-r--r-- | vendor/derivative/doc/Clone.md | 38 | ||||
-rw-r--r-- | vendor/derivative/doc/Debug.md | 153 | ||||
-rw-r--r-- | vendor/derivative/doc/Default.md | 106 | ||||
-rw-r--r-- | vendor/derivative/doc/Hash.md | 83 | ||||
-rw-r--r-- | vendor/derivative/doc/README.md | 125 | ||||
-rw-r--r-- | vendor/derivative/doc/SUMMARY.md | 25 | ||||
-rw-r--r-- | vendor/derivative/doc/cmp.md | 123 | ||||
-rw-r--r-- | vendor/derivative/doc/custom.css | 24 | ||||
-rw-r--r-- | vendor/derivative/doc/debug-transparent-orig.rs | 8 | ||||
-rw-r--r-- | vendor/derivative/doc/debug-transparent.rs | 5 | ||||
-rw-r--r-- | vendor/derivative/doc/default-enum-orig.rs | 19 | ||||
-rw-r--r-- | vendor/derivative/doc/default-enum.rs | 11 | ||||
-rw-r--r-- | vendor/derivative/doc/default-value-orig.rs | 27 | ||||
-rw-r--r-- | vendor/derivative/doc/default-value.rs | 18 | ||||
-rw-r--r-- | vendor/derivative/doc/eq-ignore-orig.rs | 40 | ||||
-rw-r--r-- | vendor/derivative/doc/eq-ignore.rs | 26 | ||||
-rw-r--r-- | vendor/derivative/doc/styles/website.css | 11 |
17 files changed, 842 insertions, 0 deletions
diff --git a/vendor/derivative/doc/Clone.md b/vendor/derivative/doc/Clone.md new file mode 100644 index 000000000..25ea2158b --- /dev/null +++ b/vendor/derivative/doc/Clone.md @@ -0,0 +1,38 @@ +# Custom attributes + +The `Copy` and `Clone` traits support the following attributes: + +* **Container attributes** + * [`<Copy or Clone>(bound="<where-clause or empty>")`](#custom-bound) + * [`Clone(clone_from="true")`](#clone-from) +* **Field attributes** + * [`<Copy or Clone>(bound="<where-clause or empty>")`](#custom-bound) + +# `clone_from` + +The [`Clone`] trait has a default implementation for [`clone_from`] and +`derive(Clone)` never implements that method. *derivative* can implement it if +asked explicitly. + +Note that while the generated implementation is good for structures, it might +not be very efficient for enumerations. What it does is check if both `self` +and the clone-from value have the same variant, if they have, use `clone_from` +on the members, otherwise fallback to `*self = other.clone();`. Ask yourself if +you really need this. + +# Custom bound +As most other traits, `Copy` and `Debug` support a custom bound on container +and fields. See [`Debug`'s documentation](Debug.md#custom-bound) for more +information. + +# Limitations + +*rustc* can optimize `derive(Clone, Copy)` to generate faster, smaller code. +So does *derivative*. But *rustc* does not know about `derivative(Copy)` and +would not optimize `#[derivative(Copy)] #[derive(Clone)]`. +To avoid that issue, you should avoid deriving `Clone` using *rustc*'s default +`derive` and `Copy` using `derivative`. *derivative* will error if it detects +that, but can't always do it. + +[`Clone`]: https://doc.rust-lang.org/std/clone/trait.Clone.html +[`clone_from`]: https://doc.rust-lang.org/std/clone/trait.Clone.html#method.clone_from diff --git a/vendor/derivative/doc/Debug.md b/vendor/derivative/doc/Debug.md new file mode 100644 index 000000000..25b66be2e --- /dev/null +++ b/vendor/derivative/doc/Debug.md @@ -0,0 +1,153 @@ +# Custom attributes +The `Debug` trait supports the following attributes: + +* **Container attributes** + * [`Debug(bound="<where-clause or empty>")`](#custom-bound) + * [`Debug="transparent"`](#hiding-newtypes) +* **Variant attributes** + * [`Debug="transparent"`](#hiding-newtypes) +* **Field attributes** + * [`Debug(bound="<where-clause or empty>")`](#custom-bound) + * [`Debug(format_with="<path>")`](#format-with) + * [`Debug="ignore"`](#ignoring-a-field) + +# Ignoring a field + +You can use *derivative* to hide fields from a structure or enumeration `Debug` +implementation: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Debug)] +struct Foo { + foo: u8, + #[derivative(Debug="ignore")] + bar: u8, +} + +println!("{:?}", Foo { foo: 42, bar: 1 }); // Foo { foo: 42 } +``` + +# Hiding newtypes + +You can use *derivative* to automatically unwrap newtypes and enumeration +variants with only one field: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Debug="transparent")] +struct A(isize); + +#[derive(Derivative)] +#[derivative(Debug)] +enum C { + Foo(u8), + #[derivative(Debug="transparent")] + Bar(u8), +} + +println!("{:?}", A(42)); // 42 +println!("{:?}", C::Bar(42)); // 42 + +// But: +println!("{:?}", C::Foo(42)); // Foo(42) +``` + +# Format with + +You can pass a field to a format function: + +```rust +# extern crate derivative; +# use derivative::Derivative; +# mod path { +# pub struct SomeTypeThatMightNotBeDebug; +# pub mod to { +# pub fn my_fmt_fn(_: &super::SomeTypeThatMightNotBeDebug, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { unimplemented!() } +# } +# } +# use path::SomeTypeThatMightNotBeDebug; +#[derive(Derivative)] +#[derivative(Debug)] +struct Foo { + foo: u32, + #[derivative(Debug(format_with="path::to::my_fmt_fn"))] + bar: SomeTypeThatMightNotBeDebug, +} +``` + +The field `bar` will be displayed with `path::to::my_fmt_fn(&bar, &mut fmt)` +where `fmt` is the current [`Formatter`]. + +The function must the following prototype: + +```rust,ignore +fn fmt(&T, &mut std::fmt::Formatter) -> Result<(), std::fmt::Error>; +``` + +# Custom bound + +Usually, *derivative* will add a `T: Debug` bound for each type parameter `T` +of the current type. If you do not want that, you can specify an explicit bound: + +* Either on the type. This replaces all bounds: + +```rust +# extern crate derivative; +# use derivative::Derivative; +# trait MyDebug { +# fn my_fmt(&self, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error>; +# } +# use std::fmt::Debug; +#[derive(Derivative)] +#[derivative(Debug(bound="T: Debug, U: MyDebug"))] +struct Foo<T, U> { + foo: T, + #[derivative(Debug(format_with="MyDebug::my_fmt"))] + bar: U, +} +``` + +* Or on a field. This replaces the bound *derivative* guessed for that field. The example below is equivalent to the above: + +```rust +# extern crate derivative; +# use derivative::Derivative; +# trait MyDebug { +# fn my_fmt(&self, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error>; +# } +#[derive(Derivative)] +#[derivative(Debug)] +struct Foo<T, U> { + foo: T, + #[derivative(Debug(format_with="MyDebug::my_fmt", bound="U: MyDebug"))] + bar: U, +} +``` + +With `bound=""` it is possible to remove any bound for the type. This is useful +if your type contains a `Foo<T>` that is `Debug` even if `T` is not. + +[`Formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html + +# Packed structures + +You can use *derivative* to implement `Debug` on packed structures. Unlike the standard `derive(debug)`, *derivative* does not require the structure itself to be `Copy`, but like the standard `derive(debug)`, it requires each (non-ignored) field to be `Copy`. + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Debug)] +#[repr(C, packed)] +struct Foo { + foo: u8, + // `String` isn't `Copy` so it must be ignored to derive `Debug` + #[derivative(Debug="ignore")] + bar: String, +} +```
\ No newline at end of file diff --git a/vendor/derivative/doc/Default.md b/vendor/derivative/doc/Default.md new file mode 100644 index 000000000..f61bbc9a7 --- /dev/null +++ b/vendor/derivative/doc/Default.md @@ -0,0 +1,106 @@ +# Custom attributes +The `Default` trait supports the following attributes: + +* **Container attributes** + * [`Default(bound="<where-clause or empty>")`](#custom-bound) + * [`Default="new"`](#new-function) +* **Variant attributes** + * [`Default`](#default-enumeration) +* **Field attributes** + * [`Default(bound="<where-clause or empty>")`](#custom-bound) + * [`Default(value="<expr>")`](#setting-the-value-of-a-field) + +# Default enumeration + +You can use *derivative* to derive a default implementation on enumerations! +This does not work with *rustc*'s `#[derive(Default)]`. +All you need is to specify what variant is the default value: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Debug, Derivative)] +#[derivative(Default)] +enum Enum { + A, + #[derivative(Default)] + B, +} + +println!("{:?}", Enum::default()); // B +``` + +# Setting the value of a field + +You can use *derivative* to change the default value of a field in a `Default` +implementation: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Debug, Derivative)] +#[derivative(Default)] +struct Foo { + foo: u8, + #[derivative(Default(value="42"))] + bar: u8, +} + +println!("{:?}", Foo::default()); // Foo { foo: 0, bar: 42 } +``` + +# `new` function + +You can use *derivative* to derive a convenience `new` method for your type +that calls `Default::default`: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Debug, Derivative)] +#[derivative(Default(new="true"))] +struct Foo { + foo: u8, + bar: u8, +} + +println!("{:?}", Foo::new()); // Foo { foo: 0, bar: 0 } +``` + +# Custom bound + +The following does not work because `derive` adds a `T: Default` bound on the +`impl Default for Foo<T>`: + +```rust,compile_fail +# extern crate derivative; +# use derivative::Derivative; +#[derive(Default)] +struct Foo<T> { + foo: Option<T>, +} + +struct NonDefault; + +Foo::<NonDefault>::default(); // gives: +// error: no associated item named `default` found for type `Foo<NonDefault>` in the current scope +// = note: the method `default` exists but the following trait bounds were not satisfied: `NonDefault : std::default::Default` +``` + +That bound however is useless as `Option<T>: Default` for any `T`. +`derivative` allows you to explicitly specify a bound if the inferred one is not +correct: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Default(bound=""))] // don't need any bound +struct Foo<T> { + foo: Option<T>, +} + +struct NonDefault; + +Foo::<NonDefault>::default(); // works! +``` diff --git a/vendor/derivative/doc/Hash.md b/vendor/derivative/doc/Hash.md new file mode 100644 index 000000000..71c6f0867 --- /dev/null +++ b/vendor/derivative/doc/Hash.md @@ -0,0 +1,83 @@ +# Custom attributes +The `Hash` trait supports the following attributes: + +* **Container attributes** + * [`Hash(bound="<where-clause or empty>")`](#custom-bound) +* **Field attributes** + * [`Hash(bound="<where-clause or empty>")`](#custom-bound) + * [`Hash(hash_with="<path>")`](#hash-with) + * [`Hash="ignore"`](#ignoring-a-field) + +# Ignoring a field + +You can use *derivative* to ignore fields from a `Hash` implementation: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Hash)] +struct Foo { + foo: u8, + #[derivative(Hash="ignore")] + bar: i32, +} + +#[derive(Hash)] +struct Bar { + foo: u8, +} + +# fn hash<T: std::hash::Hash>(t: &T) -> u64 { +# use std::hash::Hasher; +# let mut s = std::collections::hash_map::DefaultHasher::new(); +# t.hash(&mut s); +# s.finish() +# } +# +assert_eq!(hash(&Foo { foo: 42, bar: -1337 }), hash(&Bar { foo: 42 })); +``` + +# Hash with + +You can pass a field to a hash function: + +```rust +# extern crate derivative; +# use derivative::Derivative; +# mod path { +# pub struct SomeTypeThatMightNotBeHash; +# pub mod to { +# pub fn my_hash_fn<H>(_: &super::SomeTypeThatMightNotBeHash, state: &mut H) where H: std::hash::Hasher { unimplemented!() } +# } +# } +# use path::SomeTypeThatMightNotBeHash; +#[derive(Derivative)] +#[derivative(Hash)] +struct Foo { + foo: u32, + #[derivative(Hash(hash_with="path::to::my_hash_fn"))] + bar: SomeTypeThatMightNotBeHash, +} +``` + +The field `bar` will be hashed with `path::to::my_hash_fn(&bar, &mut state)` +where `state` is the current [`Hasher`]. + +The function must the following prototype: + +```rust,ignore +fn my_hash_fn<H>(&T, state: &mut H) where H: Hasher; +``` + +# Limitations + +On structure, `derivative(Hash)` will produce the same hash as `derive(Hash)`. +On unions however, it will produces the same hashes *only for unitary +variants*! + +# Custom bound +As most other traits, `Hash` supports a custom bound on container and fields. +See [`Debug`'s documentation](Debug.md#custom-bound) for more information. + +[`Hasher`]: https://doc.rust-lang.org/std/hash/trait.Hasher.html diff --git a/vendor/derivative/doc/README.md b/vendor/derivative/doc/README.md new file mode 100644 index 000000000..62d73bca4 --- /dev/null +++ b/vendor/derivative/doc/README.md @@ -0,0 +1,125 @@ +# Derivative + +This crate provides a set of alternative `#[derive]` attributes for Rust. + +## Examples + +*derivative* uses attributes to make it possible to derive more implementations +than the built-in `derive(Trait)`. Here are a few examples of stuffs you cannot +just `derive`. + +You can derive `Default` on enumerations: + +<table> +<tr> +<th> + +With *derivative* +</th> +<th> + +[Original][default-value-source] +</th> +</tr> +<tr> +</tr> +<tr class="readme-example"> +<td> + +{{#playground default-enum.rs}} +</td> +<td> + +{{#playground default-enum-orig.rs}} +</td> +</tr> +</table> + +You can use different default values for some fields: + +<table> +<tr> +<th> + +With *derivative* +</th> +<th> + +[Original][default-value-source] +</th> +</tr> +<tr> +</tr> +<tr class="readme-example"> +<td> + +{{#playground default-value.rs}} +</td> +<td> + +{{#playground default-value-orig.rs}} +</td> +</tr> +</table> + + +Want a transparent `Debug` implementation for your wrapper? We got that: + +<table> +<tr> +<th> + +With *derivative* +</th> +<th> + +[Original][transparent-source] +</th> +</tr> +<tr> +</tr> +<tr class="readme-example"> +<td> + +{{#playground debug-transparent.rs}} +</td> +<td> + +{{#playground debug-transparent-orig.rs}} +</td> +</tr> +</table> + + +Need to ignore a field? We got that too: + +<table> +<tr> +<th> + +With *derivative* +</th> +<th> + +[Original][eq-ignore-source] +</th> +</tr> +<tr> +</tr> +<tr class="readme-example"> +<td> + +{{#playground eq-ignore.rs}} +</td> +<td> + +{{#playground eq-ignore-orig.rs}} +</td> +</tr> +</table> + + +[default-value-source]: https://github.com/rust-lang-nursery/regex/blob/3cfef1e79d135a3e8a670aff53e7fabef453a3e1/src/re_builder.rs#L12-L39 +[default-enum-source]: https://github.com/rust-lang/rust/blob/16eeeac783d2ede28e09f2a433c612dea309fe33/src/libcore/option.rs#L714-L718 +[transparent-source]: https://github.com/rust-lang/rust/blob/5457c35ece57bbc4a65baff239a02d6abb81c8a2/src/libcore/num/mod.rs#L46-L54 +[eq-ignore-source]: https://github.com/steveklabnik/semver/blob/baa0fbb57c80a7fb344fbeedac24a28439ddf5b5/src/version.rs#L196-L205 diff --git a/vendor/derivative/doc/SUMMARY.md b/vendor/derivative/doc/SUMMARY.md new file mode 100644 index 000000000..66762936f --- /dev/null +++ b/vendor/derivative/doc/SUMMARY.md @@ -0,0 +1,25 @@ +# Summary + +* [Overview](README.md) +* [`Copy` and `Clone` traits](Clone.md) + <!-- * [`clone_from`](Clone.md#clone-from) --> + <!-- * [Custom bound](Clone.md#custom-bound) --> +* [`Debug` trait](Debug.md) + <!-- * [Hiding fields](Debug.md#ignoring-a-field) --> + <!-- * [Hiding newtypes](Debug.md#hiding-newtypes) --> + <!-- * [Alternative format function](Debug.md#format-with) --> + <!-- * [Custom bound](Debug.md#custom-bound) --> +* [`Default` trait](Default.md) + <!-- * [Default enumeration](Default.md#default-enumeration) --> + <!-- * [Setting the value of a field](Default.md#setting-the-value-of-a-field) --> + <!-- * [`new` function](Default.md#new-function) --> + <!-- * [Custom bound](Default.md#custom-bound) --> +* [`Hash` trait](Hash.md) + <!-- * [Ignoring fields](Hash.md#ignoring-a-field) --> + <!-- * [Alternative hash function](Debug.md#hash-with) --> + <!-- * [Custom bound](Hash.md#custom-bound) --> +* [Comparison traits](cmp.md) + <!-- * [Note about enumerations](cmp.md#enumerations) --> + <!-- * [Ignoring fields](cmp.md#ignoring-a-field) --> + <!-- * [Alternative comparison function](cmp.md#compare-with) --> + <!-- * [Custom bound](cmp.md#custom-bound) --> diff --git a/vendor/derivative/doc/cmp.md b/vendor/derivative/doc/cmp.md new file mode 100644 index 000000000..b6ff4903e --- /dev/null +++ b/vendor/derivative/doc/cmp.md @@ -0,0 +1,123 @@ +# Custom attributes +The `PartialEq`, `Eq`, `PartialOrd` and `Eq` and traits support the following attributes: + +* **Container attributes** + * [`<CmpTrait>(bound="<where-clause or empty>")`](#custom-bound) +* **Field attributes** + * [`<CmpTrait>(bound="<where-clause or empty>")`](#custom-bound) + +The `PartialEq`, `PartialOrd` and `Ord` traits also supports the following attributes: + +* **Container attributes** + * [`<CmpTrait>="feature_allow_slow_enum"`](#enumerations) +* **Field attributes** + * [`<CmpTrait>="ignore"`](#ignoring-a-field) + * [`<CmpTrait>(compare_with="<path>")`](#compare-with) + +(These attributes are not relevant for `Eq` which is just a marker trait.) + +# Enumerations + +Unfortunately, there is no way for derivative to derive `PartialOrd` or `Ord` on +enumerations as efficiently as the built-in `derive(…)` yet. + +If you want to use derivative on enumerations anyway, you can add + +```rust,ignore +#[derivative(PartialOrd="feature_allow_slow_enum")] +``` + +to your enumeration. This acts as a “feature-gate”. + +This attribute is also allowed for `PartialEq` for historical reason. It is not +necessary anymore as of v2.1.0. It was never necessary nor allowed for `Eq`. + +# Ignoring a field + +You can use *derivative* to ignore a field when comparing: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(PartialEq)] +struct Foo { + foo: u8, + #[derivative(PartialEq="ignore")] + bar: u8, +} + +assert!(Foo { foo: 0, bar: 42 } == Foo { foo: 0, bar: 7}); +assert!(Foo { foo: 42, bar: 0 } != Foo { foo: 7, bar: 0}); +``` + +# Compare with + +Usually fields are compared using `==`, `PartialOrd::partial_cmp` or `Ord::cmp`. You can use an alternative comparison +function if you like: + +```rust +# extern crate derivative; +# use derivative::Derivative; +# mod path { +# pub struct SomeTypeThatMightNotBePartialEq; +# pub mod to { +# pub fn my_cmp_fn(_: &super::SomeTypeThatMightNotBePartialEq, _: &super::SomeTypeThatMightNotBePartialEq) -> bool { false } +# } +# } +# use path::SomeTypeThatMightNotBePartialEq; +#[derive(Derivative)] +#[derivative(PartialEq)] +struct Foo { + foo: u32, + #[derivative(PartialEq(compare_with="path::to::my_cmp_fn"))] + bar: SomeTypeThatMightNotBePartialEq, +} +``` + +`foo` will be compared with `==` and `bar` will be compared with +`path::to::my_cmp_fn` which must have the following prototype: + +| Trait | Signature | +|--------------|-----------| +| `PartialEq` | <span class="rust">`fn my_cmp_fn(&T, &T) -> bool;`</span> +| `PartialOrd` | <span class="rust">`fn my_cmp_fn(&T, &T) -> std::option::Option<std::cmp::Ordering>;`</span> +| `Ord` | <span class="rust">`fn my_cmp_fn(&T, &T) -> std::cmp::Ordering;`</span> + +# Custom bound + +Usually if you derive `CmpTrait`, a `T: CmpTrait` bound is added for each type parameter `T`. You can use +override this behavior if the inferred bound is not correct for you. + +Eg. comparing raw pointers does not require the type to be `Eq`, so you could +use: + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(PartialEq)] +struct WithPtr<T: ?Sized> { + #[derivative(PartialEq(bound=""))] + foo: *const T +} +``` + +See [`Default`'s documentation](./Default.md#custom-bound) for more details. + +# Packed structures + +You can use *derivative* to implement the comparison traits on packed structures. Unlike the standard `derive`, *derivative* does not require the structure itself to be `Copy`, but like the standard `derive`, it requires each (non-ignored) field to be `Copy`. + +```rust +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(PartialEq)] +#[repr(C, packed)] +struct Foo { + f: u32, + #[derivative(PartialEq = "ignore")] + t: String, +} +```
\ No newline at end of file diff --git a/vendor/derivative/doc/custom.css b/vendor/derivative/doc/custom.css new file mode 100644 index 000000000..3ccc00806 --- /dev/null +++ b/vendor/derivative/doc/custom.css @@ -0,0 +1,24 @@ +#content > main > table { + position: relative; + left: 50%; + transform: translateX(-50%); + + margin-left: 0px; + margin-right: 0px; +} + +#content > main > table td { + vertical-align: top; +} + +#content > main > table .hljs { + background: none; +} + +.readme-example { + background: #f1f1f1; +} + +table .readme-example > td { + border: 1px hsl(0, 0%, 0%) solid; +}
\ No newline at end of file diff --git a/vendor/derivative/doc/debug-transparent-orig.rs b/vendor/derivative/doc/debug-transparent-orig.rs new file mode 100644 index 000000000..387ab7f74 --- /dev/null +++ b/vendor/derivative/doc/debug-transparent-orig.rs @@ -0,0 +1,8 @@ +# use std::fmt; +pub struct Wrapping<T>(pub T); + +impl<T: fmt::Debug> fmt::Debug for Wrapping<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +}
\ No newline at end of file diff --git a/vendor/derivative/doc/debug-transparent.rs b/vendor/derivative/doc/debug-transparent.rs new file mode 100644 index 000000000..227049589 --- /dev/null +++ b/vendor/derivative/doc/debug-transparent.rs @@ -0,0 +1,5 @@ +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Debug="transparent")] +pub struct Wrapping<T>(pub T);
\ No newline at end of file diff --git a/vendor/derivative/doc/default-enum-orig.rs b/vendor/derivative/doc/default-enum-orig.rs new file mode 100644 index 000000000..4f459d77d --- /dev/null +++ b/vendor/derivative/doc/default-enum-orig.rs @@ -0,0 +1,19 @@ +# #![no_implicit_prelude] +# extern crate core; +# use core::default::Default; +# use Option::None; +# +pub enum Option<T> { + /// No value + None, + /// Some value `T` + Some(T), +} + +impl<T> Default for Option<T> { + /// Returns None. + #[inline] + fn default() -> Option<T> { + None + } +} diff --git a/vendor/derivative/doc/default-enum.rs b/vendor/derivative/doc/default-enum.rs new file mode 100644 index 000000000..79ec81eb0 --- /dev/null +++ b/vendor/derivative/doc/default-enum.rs @@ -0,0 +1,11 @@ +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Default(bound=""))] +pub enum Option<T> { + #[derivative(Default)] + /// No value + None, + /// Some value `T` + Some(T), +}
\ No newline at end of file diff --git a/vendor/derivative/doc/default-value-orig.rs b/vendor/derivative/doc/default-value-orig.rs new file mode 100644 index 000000000..6e016cc64 --- /dev/null +++ b/vendor/derivative/doc/default-value-orig.rs @@ -0,0 +1,27 @@ +pub struct RegexOptions { + pub pats: Vec<String>, + pub size_limit: usize, + pub dfa_size_limit: usize, + pub case_insensitive: bool, + pub multi_line: bool, + pub dot_matches_new_line: bool, + pub swap_greed: bool, + pub ignore_whitespace: bool, + pub unicode: bool, +} + +impl Default for RegexOptions { + fn default() -> Self { + RegexOptions { + pats: vec![], + size_limit: 10 * (1 << 20), + dfa_size_limit: 2 * (1 << 20), + case_insensitive: false, + multi_line: false, + dot_matches_new_line: false, + swap_greed: false, + ignore_whitespace: false, + unicode: true, + } + } +}
\ No newline at end of file diff --git a/vendor/derivative/doc/default-value.rs b/vendor/derivative/doc/default-value.rs new file mode 100644 index 000000000..deced9836 --- /dev/null +++ b/vendor/derivative/doc/default-value.rs @@ -0,0 +1,18 @@ +# extern crate derivative; +# use derivative::Derivative; +#[derive(Derivative)] +#[derivative(Default)] +pub struct RegexOptions { + pub pats: Vec<String>, + #[derivative(Default(value="10 * (1 << 20)"))] + pub size_limit: usize, + #[derivative(Default(value="2 * (1 << 20)"))] + pub dfa_size_limit: usize, + pub case_insensitive: bool, + pub multi_line: bool, + pub dot_matches_new_line: bool, + pub swap_greed: bool, + pub ignore_whitespace: bool, + #[derivative(Default(value="true"))] + pub unicode: bool, +}
\ No newline at end of file diff --git a/vendor/derivative/doc/eq-ignore-orig.rs b/vendor/derivative/doc/eq-ignore-orig.rs new file mode 100644 index 000000000..235a74959 --- /dev/null +++ b/vendor/derivative/doc/eq-ignore-orig.rs @@ -0,0 +1,40 @@ +# use std::{cmp, hash}; +# #[derive(PartialEq, Hash)] +# struct Identifier; +pub struct Version { + /// The major version. + pub major: u64, + /// The minor version. + pub minor: u64, + /// The patch version. + pub patch: u64, + /// The pre-release version identifier. + pub pre: Vec<Identifier>, + /// The build metadata, ignored when + /// determining version precedence. + pub build: Vec<Identifier>, +} + +impl cmp::PartialEq for Version { + #[inline] + fn eq(&self, other: &Version) -> bool { + // We should ignore build metadata + // here, otherwise versions v1 and + // v2 can exist such that !(v1 < v2) + // && !(v1 > v2) && v1 != v2, which + // violate strict total ordering rules. + self.major == other.major && + self.minor == other.minor && + self.patch == other.patch && + self.pre == other.pre + } +} + +impl hash::Hash for Version { + fn hash<H: hash::Hasher>(&self, into: &mut H) { + self.major.hash(into); + self.minor.hash(into); + self.patch.hash(into); + self.pre.hash(into); + } +}
\ No newline at end of file diff --git a/vendor/derivative/doc/eq-ignore.rs b/vendor/derivative/doc/eq-ignore.rs new file mode 100644 index 000000000..a83af2c61 --- /dev/null +++ b/vendor/derivative/doc/eq-ignore.rs @@ -0,0 +1,26 @@ +# extern crate derivative; +# use derivative::Derivative; +# #[derive(PartialEq, Hash)] +# struct Identifier; +#[derive(Derivative)] +#[derivative(PartialEq, Hash)] +pub struct Version { + /// The major version. + pub major: u64, + /// The minor version. + pub minor: u64, + /// The patch version. + pub patch: u64, + /// The pre-release version identifier. + pub pre: Vec<Identifier>, + // We should ignore build metadata + // here, otherwise versions v1 and + // v2 can exist such that !(v1 < v2) + // && !(v1 > v2) && v1 != v2, which + // violate strict total ordering rules. + #[derivative(PartialEq="ignore")] + #[derivative(Hash="ignore")] + /// The build metadata, ignored when + /// determining version precedence. + pub build: Vec<Identifier>, +}
\ No newline at end of file diff --git a/vendor/derivative/doc/styles/website.css b/vendor/derivative/doc/styles/website.css new file mode 100644 index 000000000..55351deba --- /dev/null +++ b/vendor/derivative/doc/styles/website.css @@ -0,0 +1,11 @@ +code .hljs-meta { + color: #969896 +} + +code .hljs-meta-string { + color: #183691 +} + +code .hljs-title { + color: #a71d5d !important +} |