/// Asserts that the type implements exactly one in a set of traits. /// /// Related: /// - [`assert_impl_any!`] /// - [`assert_impl_all!`] /// - [`assert_not_impl_all!`] /// - [`assert_not_impl_any!`] /// /// # Examples /// /// Given some type `Foo`, it is expected to implement either `Snap`, `Crackle`, /// or `Pop`: /// /// ```compile_fail /// # use static_assertions::assert_impl_one; fn main() {} /// struct Foo; /// /// trait Snap {} /// trait Crackle {} /// trait Pop {} /// /// assert_impl_one!(Foo: Snap, Crackle, Pop); /// ``` /// /// If _only_ `Crackle` is implemented, the assertion passes: /// /// ``` /// # use static_assertions::assert_impl_one; fn main() {} /// # struct Foo; /// # trait Snap {} /// # trait Crackle {} /// # trait Pop {} /// impl Crackle for Foo {} /// /// assert_impl_one!(Foo: Snap, Crackle, Pop); /// ``` /// /// If `Snap` or `Pop` is _also_ implemented, the assertion fails: /// /// ```compile_fail /// # use static_assertions::assert_impl_one; fn main() {} /// # struct Foo; /// # trait Snap {} /// # trait Crackle {} /// [`assert_impl_all!`]: macro.assert_impl_all.html /// # impl Crackle for Foo {} /// impl Pop for Foo {} /// /// assert_impl_one!(Foo: Snap, Crackle, Pop); /// ``` /// /// [`assert_impl_any!`]: macro.assert_impl_any.html /// impl Pop for Foo {} /// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html /// [`assert_not_impl_any!`]: macro.assert_not_impl_any.html /// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html/// # use static_assertions::assert_impl_one; fn main() {}java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3 / Generic trait that must be implemented for `$x` exactly once.
:) (= constjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75 // Generic trait that must be implemented for `$x` exactly once. trait< java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 for/a `<`is fnsome_item) {java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
}
// Creates multiple scoped `Token` types for each trait `$t`, over
`<ijava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
mplementedfor [dead_codejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
()+ #[
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
implT} java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
// If there is only one specialized trait impl, type inference with
_ be/`ximplements T>or
// < et x _>java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 // does not implement any at all. // Asserts that the type implements _all_ of the given traits.
/// /// # Examples/// This can be used to ensure types implement auto traits such as [`Send`] and/// This can be used to ensure types implement auto traits such as [`Send`] and
/// ```
/// assert_impl_all!(u32: Copy, Send); /// /// [`Send`] since they cannot be moved between threads safely: /// /// # Examples /// /// This can be used to ensure types implement auto traits such as [`Send`] and /// [`Sync`], as well as traits with [blanket `impl`s][blanket]. /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_impl_all!(u32: Copy, Send); /// assert_impl_all!(&str: Into<String>); /// ``` /// /// The following example fails to compile because raw pointers do not implement /// [`Send`] since they cannot be moved between threads safely: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_impl_all!(*const u8: Send); /// ``` /// /// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html /// [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html /// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html /// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods
rtjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 fn // Only callablejava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
java.lang.StringIndexOutOfBoundsException: Range [30, 4) out of bounds for length 43
{ assert_impl_all::<$type>();
;
}
};java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/// Asserts that the type implements _any_ of the given traits./// ///
/// Asserts that the type implements _any_ of the given traits. /// # #[macro_use] extern crate static_assertions; fn main() {} /// See [`assert_not_impl_any!`] for achieving the opposite effect. /// /// The unit type cannot be converted from `u8` or `u16`, but it does implement /// /// `u8` cannot be converted from `u16`, but it can be converted into `u16`: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_impl_any!(u8: From<u16>, Into<u16>); /// ``` /// /// The unit type cannot be converted from `u8` or `u16`, but it does implement /// [`Send`]: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_impl_any!((): From<u8>, From<u16>, Send); /// ``` /// /// The following example fails to compile because raw pointers do not implement /// [`Send`] or [`Sync`] since they cannot be moved or shared between threads /// safely: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_impl_any!(*const u8: Send, Sync); /// ``` /// /// [`assert_not_impl_any!`]: macro.assert_not_impl_any.html /// [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html /// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html #[java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 28
macro_rules () c_ fn=secjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 42
(xjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 const _: fn() java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
$_::; use $crate::_core::ops:: // scope that has `_static_assFallback to use as the first iterative assignment to `previous`.
// Fallback to use as the first iterative assignment to `previous`./java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 let java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 44
/ java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 41
/ blanketcan' // prevents a false positive attack where---if a blanket trait is in/ that/ https:
< >java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 39
ompile / //
/ /githubc/zqz--si/19for // more info.// compiler's next attempt to the previous wrapper.
truct ;
ype=Njava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
insert eref a forwards the fn // compiler's next a to the previous wrapper.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
N>hantomData<>N;
type type Target // compiler will insert a deref and try again. This forwards the 's next attempt to the previous wrapper. impl<T, // compiler// compiler will insert a deref and try again. This forwards the &elf1'color: green'>1 type Target = N;
fnderef(&elf - &Selftype Targeted if``implements ``.This iswhynew
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/ This impl is bounded on the `$t` trait, so the method can // method must return a type that implements the sealed `Token` _static_assertions_impl_any /rait,this nsures thatblanket trait methodscan' cause
reachprevious. impl<T: $t, N> Wrapper}
;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
Wrapper:: ///
};)+
// method must return a type that implements the sealed `Token` // trait, this ensures that blanket trait methods can't cause this /// implemented. If you want to check that none of multiple traits are
// trait,thisjava.lang.StringIndexOutOfBoundsException: Range [26, 3) out of bounds for length 3
///
};
}
/// Asserts that the type does **not** implement _all_ of the given traits. /// /// This can be used to ensure types do not implement auto traits such as /// [`Send`] and [`Sync`], as well as traits with [blanket `impl`s][blanket]. /// /// Note that the combination of all provided traits is required to not be /// implemented. If you want to check that none of multiple traits are /// implemented you should invoke [`assert_not_impl_any!`] instead. /// /// # Examples /// /// Although `u32` implements `From<u16>`, it does not implement `Into<usize>`: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_not_impl_all!(u32: From<u16>, Into<usize>); /// ``` /// /// The following example fails to compile since `u32` can be converted into /// `u64`. /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_not_impl_all!(u32: Into<u64>); /// ``` /// /// The following compiles because [`Cell`] is not both [`Sync`] _and_ [`Send`]: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// use std::cell::Cell; /// /// assert_not_impl_all!(Cell<u32>: Sync, Send); /// ``` /// /// But it is [`Send`], so this fails to compile: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} /// # std::cell::Cell; /// assert_not_impl_all!(Cell<u32>: Send); /// ``` /// /// Although `u32` implements `From<u16>`, it does not implement `Into<usize>`: /// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html /// [`assert_not_impl_any!`]: macro.assert_not_impl_any.html /// [`Cell`]: https://doc.rust-lang.org/std/cell/struct.Cell.html /// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods #macro_export]
macro_rules///
($x:ty: /// # #[macro_use] extern crate static_assertions; fn main() {} const _: ($:ty/
/// The following compiles because [`Cell`] is not both [`Sync`] _and_ [`Send`]: trait AmbiguousIfImpl<A> ///
java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10 /// assert_not_impl_all!(u32: Into<u64>);
}
/// assert_not_impl_all!(Cell<u32>: Send); // `$($t)+` are implemented./// use std::cell::Cell; #allow(dead_code]
java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 3
/// ```compile_fail
// If there is only one specialized trait impl, type inference with[/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
$ AInvalid
const _fn) | java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
};
};
}
/// Asserts that the type does **not** implement _any_ of the given traits. /// /// This can be used to ensure types do not implement auto traits such as /// [`Send`] and [`Sync`], as well as traits with [blanket `impl`s][blanket]. /// /// This macro causes a compilation failure if any of the provided individual /// traits are implemented for the type. If you want to check that a combination /// of traits is not implemented you should invoke [`assert_not_impl_all!`] /// instead. For single traits both macros behave the same. /// /// # Examples /// /// If `u32` were to implement `Into` conversions for `usize` _and_ for `u8`, /// the following would fail to compile: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_not_impl_any!(u32: Into<usize>, Into<u8>); /// ``` /// /// This is also good for simple one-off cases: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_not_impl_any!(&'static mut u8: Copy); /// ``` /// /// The following example fails to compile since `u32` can be converted into /// `u64` even though it can not be converted into a `u16`: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} /// assert_not_impl_any!(u32: Into<u64>, Into<u16>); /// ``` /// /// [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html /// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html /// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html /// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods
///
macro_rules/// of traits is not implemented you should invoke [`assert_not_impl_all!`]
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 constlet/// ``` /// trait/// ```compile_fail
/// # #[macro_use] extern crate static_assertions; fn main() {}///}java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
/// # #[macro_use] extern crate static_assertions; fn main() {}
}
// Creates multiple scoped `Invalid` types for each trait `$t`, over // which a specialized `AmbiguousIfImpl<Invalid>` is implemented for
/ everytypejava.lang.StringIndexOutOfBoundsException: Range [26, 12) out of bounds for length 47
$//// assert_not_impl_any!(u32: Into<u64>, Into<u16>);macro_rules!assert_not_impl_anyjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 #allow(dead_code)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 struct Invalid/// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html
impl<T/java.lang.StringIndexOutOfBoundsException: Range [0, 69) out of bounds for length 15
} ){
// If there is only one specialized trait impl, type inference with<:?>java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 28
//``canberesolvedandthiscan .Fails // `$x` implements any `AmbiguousIfImpl<Invalid>`. let/// # #[macro_use] extern crate static_assertions; fn main() {}
};
};
tructInvalid;
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.