[][src]Struct not_io::AllowStd

pub struct AllowStd<T>(pub T);

A simple new type wrapper holding a potential reader or writer.

This type allows the library to satisfy the compatibility across different features without having to resort to specialization. Simply put, this struct implements Read and Write:

  • for all types that implement the respective trait from std if the std feature is active.
  • on a concrete subset of those types if the alloc feature but not the std feature has been turned on.
  • only for types from core when neither feature is turned on.

Note that without this type we couldn't safely introduce a conditionally active, generic impl of our own traits. The reason is that features must only activate SemVer compatible changes. These two sets of impls are not SemVer compatible due to the uncovered generic T. In particular in the first case you'd be allowed to implement the trait for your own type that also implements std::io::Read while in the second this is an impl conflict.

  • impl Read for &'_ [u8]
  • impl<T> Read for T where std::io::Read

By adding our own private struct as a layer of indirection, you are no longer allowed to make such changes:

  • impl Read for AllowStd<&'_ [u8]>
  • impl<T> Read for AllowStd<T> where T: std::io::Read

This still means there is one impl which will never be added. Instead, the impls for core/standard types are provided separately and individually.

  • impl<T> Read for AllowStd<T> where T: crate::Read

Auto Trait Implementations

impl<T> Send for AllowStd<T> where
    T: Send

impl<T> Sync for AllowStd<T> where
    T: Sync

impl<T> Unpin for AllowStd<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.