Skip to content

Commit dc98c99

Browse files
committed
use Result instead of an absolute path to it
1 parent c29d772 commit dc98c99

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/io/read.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use core::cmp;
22

3+
use Result;
4+
35
/// Non-blocking reader trait
46
pub trait Read {
57
/// An enumeration of possible errors
@@ -17,21 +19,21 @@ pub trait Read {
1719
/// buf.len()`. The `n` value indicates that the buffer `buf` has been filled in with `n` bytes
1820
/// of data from this source. If `n == 0 && buf.len() > 0` then it can be assumed that this
1921
/// reader has run out of data and will not be able service any future read calls.
20-
fn read(&mut self, buf: &mut [u8]) -> ::Result<usize, Self::Error>;
22+
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>;
2123
}
2224

2325
impl<'a, R: ?Sized + Read> Read for &'a mut R {
2426
type Error = R::Error;
2527

26-
fn read(&mut self, buf: &mut [u8]) -> ::Result<usize, Self::Error> {
28+
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
2729
(**self).read(buf)
2830
}
2931
}
3032

3133
impl<'a> Read for &'a [u8] {
3234
type Error = !;
3335

34-
fn read(&mut self, buf: &mut [u8]) -> ::Result<usize, Self::Error> {
36+
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
3537
let len = cmp::min(self.len(), buf.len());
3638
let (head, tail) = self.split_at(len);
3739
buf[..len].copy_from_slice(head);

src/io/read_exact.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::mem;
22

33
use io::Read;
4+
use Result;
45

56
/// Creates a helper that will read from a provided reader until the provided buffer is filled.
67
///
@@ -60,7 +61,7 @@ impl<R: Read, B: AsMut<[u8]>> ReadExact<R, B> {
6061
/// error.
6162
///
6263
/// Otherwise will return `nb::Error::WouldBlock`.
63-
pub fn poll(&mut self) -> ::Result<(R, B), Error<R::Error>> {
64+
pub fn poll(&mut self) -> Result<(R, B), Error<R::Error>> {
6465
if let State::Reading { ref mut reader, ref mut buffer, ref mut position } = self.state {
6566
let buffer = buffer.as_mut();
6667
while *position < buffer.len() {

src/io/write.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use core::{cmp, mem};
22

3+
use Result;
4+
35
/// Non-blocking writer trait
46
pub trait Write {
57
/// An enumeration of possible errors
@@ -17,40 +19,40 @@ pub trait Write {
1719
/// buf.len()`. The `n` value indicates that `n` bytes from the buffer `buf` have been written
1820
/// to this source. If `n == 0 && buf.len() > 0` then it can be assumed that this writer has
1921
/// run out of space and will not be able to service future writes.
20-
fn write(&mut self, buf: &[u8]) -> ::Result<usize, Self::Error>;
22+
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>;
2123

2224
/// Attempt to flush the object, ensuring that any buffered data reach their destination.
2325
///
2426
/// On success, returns `Ok(())`.
2527
///
2628
/// If flushing cannot immediately complete, this method returns `Err(nb::Error::WouldBlock)`.
27-
fn flush(&mut self) -> ::Result<(), Self::Error>;
29+
fn flush(&mut self) -> Result<(), Self::Error>;
2830
}
2931

3032
impl<'a, W: ?Sized + Write> Write for &'a mut W {
3133
type Error = W::Error;
3234

33-
fn write(&mut self, buf: &[u8]) -> ::Result<usize, Self::Error> {
35+
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
3436
(**self).write(buf)
3537
}
3638

37-
fn flush(&mut self) -> ::Result<(), Self::Error> {
39+
fn flush(&mut self) -> Result<(), Self::Error> {
3840
(**self).flush()
3941
}
4042
}
4143

4244
impl<'a> Write for &'a mut [u8] {
4345
type Error = !;
4446

45-
fn write(&mut self, buf: &[u8]) -> ::Result<usize, Self::Error> {
47+
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
4648
let len = cmp::min(self.len(), buf.len());
4749
let (head, tail) = mem::replace(self, &mut []).split_at_mut(len);
4850
head.copy_from_slice(&buf[..len]);
4951
*self = tail;
5052
Ok(len)
5153
}
5254

53-
fn flush(&mut self) -> ::Result<(), Self::Error> {
55+
fn flush(&mut self) -> Result<(), Self::Error> {
5456
Ok(())
5557
}
5658
}

src/io/write_all.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::mem;
22

33
use io::Write;
4+
use Result;
45

56
/// Creates a helper that will write all data from the provided buffer into the provided writer.
67
///
@@ -62,7 +63,7 @@ impl<W: Write, B: AsRef<[u8]>> WriteAll<W, B> {
6263
/// error.
6364
///
6465
/// Otherwise will return `nb::Error::WouldBlock`.
65-
pub fn poll(&mut self) -> ::Result<(W, B), Error<W::Error>> {
66+
pub fn poll(&mut self) -> Result<(W, B), Error<W::Error>> {
6667
if let State::Writing { ref mut writer, ref mut buffer, ref mut position } = self.state {
6768
let buffer = buffer.as_ref();
6869
while *position < buffer.len() {

0 commit comments

Comments
 (0)