Module unreliable

Module unreliable 

Source
Available on crate features alloc and unreliable only.
Expand description

This module contains a set of functions, traits and macros that depend on undocumented standard library behavior and should therefore be used with caution.

Library tests ensure that the impls_trait checks are performed at compile time and are fully optimized with no runtime cost at opt-level >= 1. Note that the release profile uses opt-level = 3 by default.

§Reliability

While it is unlikely, there is still a possibility that functions in this module may return false negatives in future Rust versions.

The correctness of the results returned by the functions depends on the following:

  • Documented behavior that if T implements Eq, two Rcs that point to the same allocation are always equal: https://doc.rust-lang.org/1.82.0/std/rc/struct.Rc.html#method.eq.
  • Undocumented behavior that the Rc::partial_eq implementation for T: Eq will not use PartialEq::eq if both Rcs point to the same memory location.
  • The assumption that the undocumented short-circuit behavior described above will be retained for optimization purposes.

There is no formal guarantee that the undocumented behavior described above will be retained. If the implementation changes in a future Rust version, the function may return a false negative, that is, it may return false, even though T implements the trait. However, the implementation guarantees that a false positive result is impossible, i.e., the function will never return true if T does not implement the trait in any future Rust version.

Details:

Macros§

define_impls_trait_ignore_lt_fn
Generates a function which returns true if the given type implements specified trait. Note that all the lifetimes are erased and not accounted for.

Traits§

TrySpecializeWeak
A extension trait for TrySpecialize trait for specializing one completely unconstrained type to another completely unconstrained type.
WeakSpecialization
A extension trait for Specialization type for specializing one completely unconstrained type to another completely unconstrained type.

Functions§

impls_clone_weak
Returns true if the given type implements Clone.
impls_copy_weak
Returns true if the given type implements Copy.
impls_debug_weak
Returns true if the given type implements Debug.
impls_default_weak
Returns true if the given type implements Default.
impls_deref_weak
Returns true if the given type implements Deref.
impls_display_weak
Returns true if the given type implements Display.
impls_eq_weak
Returns true if the given type implements Eq.
impls_fmt_write_weak
Returns true if the given type implements FmtWrite.
impls_from_str_weak
Returns true if the given type implements FromStr.
impls_future_weak
Returns true if the given type implements Future.
impls_hash_weak
Returns true if the given type implements Hash.
impls_into_future_weak
Returns true if the given type implements IntoFuture.
impls_into_iterator_weak
Returns true if the given type implements IntoIterator.
impls_io_read_weak
Returns true if the given type implements IoRead.
impls_io_write_weak
Returns true if the given type implements IoWrite.
impls_iterator_weak
Returns true if the given type implements Iterator.
impls_lifetime_free_weak
Returns true if the given type implements LifetimeFree.
impls_ord_weak
Returns true if the given type implements Ord.
impls_partial_eq_weak
Returns true if the given type implements PartialEq.
impls_partial_ord_weak
Returns true if the given type implements PartialOrd.
impls_ref_unwind_safe_weak
Returns true if the given type implements RefUnwindSafe.
impls_send_weak
Returns true if the given type implements Send.
impls_sized_weak
Returns true if the given type implements Sized.
impls_sync_weak
Returns true if the given type implements Sync.
impls_unpin_weak
Returns true if the given type implements Unpin.
impls_unwind_safe_weak
Returns true if the given type implements UnwindSafe.