Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/media/wmf-clearkey/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 6 kB image not shown  

Quelle  assert_impl.rs

  Sprache: Rust
 

///
///
/// 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_all!`]:     macro.assert_impl_all.html
/// ```
///
/// 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 {}
/// # trait Pop {}
/// # impl Crackle for Foo {}
/// impl Pop for Foo {}
///
/// assert_impl_one!(Foo: Snap, Crackle, Pop);
/// ```
///
/// [`assert_impl_any!`]:     macro.assert_impl_any.html
/// [`assert_impl_all!`]:     macro.assert_impl_all.html
/// [`assert_not_impl_all!`]: macro.assert_not_impl_all.html
/// [`assert_not_impl_any!`]: macro.assert_not_impl_any.html
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3
o |java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
p)$(?>java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
        const:fn)= | java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
            /Generictrait< java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
                //Required for /hich  specialized`biguousIfMoreThanOne<` is
 Requiredfor actuallyjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 33
                java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 13
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13

            // Creates multiple scoped `Token` types for each trait `$t`, over
lized mbiguousIfMoreThanOneokens
            // implemented for every type that implements `$t`.
            java.lang.StringIndexOutOfBoundsException: Range [16, 12) out of bounds for length 63
                ()
                struct Token$}java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15

                impl<T: ?Sized +java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15

            
            / `_` can be resolved and this can compile. Fails to compile if
            // `$x` implements more than one `AmbiguousIfMoreThanOne<Token>` or
            // does not implement any at all.//_can be             $` implements  han  `mbiguousIfMoreThanOne<oken> or
           _=x AmbiguousIfMoreThanOne<>:ome_item;
        };
    }java.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 10
}

/// Asserts that the type implements _all_ of the given traits.
///
/// See [`assert_not_impl_all!`] for achieving the opposite effect.
///
/// # 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
#[/// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods/// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods
macro_rules/// [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
/// [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
        _ fn( =| (ype:ortjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
/ Only callable when `$type` implements all traits in `$($trait)+`.
            <T ?ized            n            fn assert_impl_all+ (,? ={
            java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
        ;
;
}

/// Asserts that the type implements _any_ of the given traits.
///
/// See [`assert_not_impl_any!`] for achieving the opposite effect.
///
/// # Examples
///
/// `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
#[/// safely:///
/// [`/// assert_impl_any!(*/// [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html/// ```
    ($/ [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
        _:)=!assert_impl_anyjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 30
                    _fn ||java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
           c::core:ops:Derefjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

            // Fallback to use as the first iterative assignment to `previous`.
letprevious =AssertImplAnyFallback;
            struct AssertImplAnyFallback;

            // Ensures that blanket traits can't impersonate the method. This
             crate:core:pserefjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Range [42, 43) out of bounds for length 0
            s  AssertImplAnyFallback
            //
            / See https://github.com/nvzqz/static-assertions-rs/issues/19 for
            moreinfo.
            struct java.lang.StringIndexOutOfBoundsException: Range [76, 25) out of bounds for length 76
            AssertImplAnyToken {}
            /Ensuresthat  traits can'//
//that has/See https:github.com/nvzqz/static-assertions-rs/issues/19 for

            $(let// more info.
uct rapperTN(PhantomData raitAssertImplAnyToken }

                 /
                        /eehttps:/c/zqzsassertionsrsssues/19for
               // compiler's next attempt to the previous wrapper.
                java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                    ype Target=Njava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

                    fn will inserta and again.  
ttemptto 
                    
                }

                // This impl is bounded on the `$t` trait, so the method can, N java.lang.StringIndexOutOfBoundsException: Range [32, 16) out of bounds for length 56
                // only be called if `$x` implements `$t`. This is why a new// compiler will insert a deref and try again. This forwards the
                // `Wrapper` is defined for each `previous`.
                s.1
                    fn _                    java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                     s)- Selfjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 76

                }

                Wrapper::                        


 /java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
                    tthis
            / macro to compile.
(revious.   java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
        };
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
}

/// 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);
/// ```
///
/// [`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_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
[
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 3
x/// ```
                    // The following compiles because [`Cell`] is not both [`Sync`] _and_ [`Send`]:
//// `u64`.
            /// use std::cell/// ```compile_fail
                // Required for actually being able to reference the trait.
                /// The following java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            o_use/// assert_not_impl_all!(Cell<u32>: Send);

            impl/// assert_not_impl_all!(Cell<u32>: Sync, Send);#)

            // Used for the specialized impl when *all* traits in
            // `$($t)+` are implemented.
            #allow(dead_code/// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods
r/// [`Sync`]: http

            impl</// [`assert_not_impl_any!`]: macro.assert_not_impl_any.html

            // If there is only one specialized trait impl, type inference with
            // `_` can be resolved and this can compile. Fails to compile if:ty://`x`implements `mbiguousIfImpl<Invalid>`.
/ assert_not_impl_all{
/// [`Send`] and [`Sync`], as well as traits with [blanket `impl`s][blanket].
        };
    };
 java.lang.StringIndexOutOfBoundsException: Range [12, 50) out of bounds for length 38

/// 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
#[            /             // every type ///
! {
    ($x:ty
        #(]
            // Generic trait with a blanket impl over `()` for all types.
            trait AmbiguousIfImpl/// [blanket]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods///
                // Required for actually being able to reference the trait.
               fnsome_item( }
            

            impl<T Sized java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 28

                                    _ be and  compile  tocompile if
            // which a specialized `AmbiguousIfImpl<Invalid>` is implemented for///
            // every type that implements `$t`.
            $({
                #[/// ```
                java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 31

                impl<Tjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            })+

            // If there is only one specialized trait impl, type inference with
            // `_` can be resolved and this can compile. Fails to compile if
            // `$x` implements any `AmbiguousIfImpl<Invalid>`.java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
            let _///
         struct Invalid;
    };
}

Messung V0.5 in Prozent
C=82 H=93 G=87

¤ 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:  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.