[−][src]Struct not_io::AllowStd
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 thestd
feature is active. - on a concrete subset of those types if the
alloc
feature but not thestd
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,
T: Send,
impl<T> Sync for AllowStd<T> where
T: Sync,
T: Sync,
impl<T> Unpin for AllowStd<T> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,