mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-12 00:00:14 +02:00
Add no_std support, by adding an std feature (#281)
To make the library work as `no_std` we add an `std` feature which is on by default. When it is off, we compile as `no_std` and make parts of the API that require `std::io` conditional on the `std` feature.
This commit is contained in:
@@ -2,6 +2,8 @@ use crate::{Buf, BufMut};
|
||||
|
||||
use either::Either;
|
||||
use either::Either::*;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::io::{IoSlice, IoSliceMut};
|
||||
|
||||
impl<L, R> Buf for Either<L, R>
|
||||
@@ -23,6 +25,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn bytes_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize {
|
||||
match *self {
|
||||
Left(ref b) => b.bytes_vectored(dst),
|
||||
@@ -64,6 +67,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
unsafe fn bytes_vectored_mut<'a>(&'a mut self, dst: &mut [IoSliceMut<'a>]) -> usize {
|
||||
match *self {
|
||||
Left(ref mut b) => b.bytes_vectored_mut(dst),
|
||||
|
||||
Reference in New Issue
Block a user