Implement Debug for File
This patch adds a `Debug` impl for `std::fs::File`. On all platforms (Unix and Windows) it shows the file descriptor. On Linux, it displays the path and access mode as well. Ideally we should show the path/mode for all platforms, not just Linux, but this will do for now. cc #24570
This commit is contained in:
parent
21c48c3e82
commit
1131bc0a0f
4 changed files with 68 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
use core::prelude::*;
|
||||
|
||||
use fmt;
|
||||
use io::{self, Error, ErrorKind, SeekFrom, Seek, Read, Write};
|
||||
use path::{Path, PathBuf};
|
||||
use sys::fs2 as fs_imp;
|
||||
|
@ -305,6 +306,12 @@ impl FromInner<fs_imp::File> for File {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for File {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Read for File {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue