refactor: use shorthand fields
This commit is contained in:
@@ -2854,7 +2854,7 @@ mod test_map {
|
||||
slot.borrow_mut()[k] += 1;
|
||||
});
|
||||
|
||||
Droppable { k: k }
|
||||
Droppable { k }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -877,7 +877,7 @@ impl OpenOptions {
|
||||
|
||||
fn _open(&self, path: &Path) -> io::Result<File> {
|
||||
let inner = fs_imp::File::open(path, &self.0)?;
|
||||
Ok(File { inner: inner })
|
||||
Ok(File { inner })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ pub struct Repeat { byte: u8 }
|
||||
/// assert_eq!(buffer, [0b101, 0b101, 0b101]);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
|
||||
pub fn repeat(byte: u8) -> Repeat { Repeat { byte } }
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Read for Repeat {
|
||||
|
||||
@@ -931,7 +931,7 @@ impl<T> fmt::Debug for Sender<T> {
|
||||
|
||||
impl<T> SyncSender<T> {
|
||||
fn new(inner: Arc<sync::Packet<T>>) -> SyncSender<T> {
|
||||
SyncSender { inner: inner }
|
||||
SyncSender { inner }
|
||||
}
|
||||
|
||||
/// Sends a value on this synchronous channel.
|
||||
|
||||
@@ -32,7 +32,7 @@ impl Instant {
|
||||
let mut t = mem::uninitialized();
|
||||
let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, &mut t);
|
||||
assert_eq!(ret, abi::errno::SUCCESS);
|
||||
Instant { t: t }
|
||||
Instant { t }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ impl SystemTime {
|
||||
let mut t = mem::uninitialized();
|
||||
let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, &mut t);
|
||||
assert_eq!(ret, abi::errno::SUCCESS);
|
||||
SystemTime { t: t }
|
||||
SystemTime { t }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct FileDesc {
|
||||
|
||||
impl FileDesc {
|
||||
pub fn new(fd: usize) -> FileDesc {
|
||||
FileDesc { fd: fd }
|
||||
FileDesc { fd }
|
||||
}
|
||||
|
||||
pub fn raw(&self) -> usize { self.fd }
|
||||
|
||||
@@ -264,7 +264,7 @@ impl File {
|
||||
pub fn file_attr(&self) -> io::Result<FileAttr> {
|
||||
let mut stat = syscall::Stat::default();
|
||||
cvt(syscall::fstat(self.0.raw(), &mut stat))?;
|
||||
Ok(FileAttr { stat: stat })
|
||||
Ok(FileAttr { stat })
|
||||
}
|
||||
|
||||
pub fn fsync(&self) -> io::Result<()> {
|
||||
|
||||
@@ -19,7 +19,7 @@ pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
impl Error {
|
||||
pub fn new(errno: i32) -> Error {
|
||||
Error { errno: errno }
|
||||
Error { errno }
|
||||
}
|
||||
|
||||
pub fn mux(result: Result<usize>) -> usize {
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Thread {
|
||||
panic!("thread failed to exit");
|
||||
} else {
|
||||
mem::forget(p);
|
||||
Ok(Thread { id: id })
|
||||
Ok(Thread { id })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ impl SystemTime {
|
||||
|
||||
impl From<syscall::TimeSpec> for SystemTime {
|
||||
fn from(t: syscall::TimeSpec) -> SystemTime {
|
||||
SystemTime { t: Timespec { t: t } }
|
||||
SystemTime { t: Timespec { t } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ fn max_len() -> usize {
|
||||
|
||||
impl FileDesc {
|
||||
pub fn new(fd: c_int) -> FileDesc {
|
||||
FileDesc { fd: fd }
|
||||
FileDesc { fd }
|
||||
}
|
||||
|
||||
pub fn raw(&self) -> c_int { self.fd }
|
||||
|
||||
@@ -317,7 +317,7 @@ impl DirEntry {
|
||||
cvt(unsafe {
|
||||
fstatat64(fd, self.entry.d_name.as_ptr(), &mut stat, libc::AT_SYMLINK_NOFOLLOW)
|
||||
})?;
|
||||
Ok(FileAttr { stat: stat })
|
||||
Ok(FileAttr { stat })
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "android")))]
|
||||
@@ -526,7 +526,7 @@ impl File {
|
||||
cvt(unsafe {
|
||||
fstat64(self.0.raw(), &mut stat)
|
||||
})?;
|
||||
Ok(FileAttr { stat: stat })
|
||||
Ok(FileAttr { stat })
|
||||
}
|
||||
|
||||
pub fn fsync(&self) -> io::Result<()> {
|
||||
@@ -807,7 +807,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
|
||||
cvt(unsafe {
|
||||
stat64(p.as_ptr(), &mut stat)
|
||||
})?;
|
||||
Ok(FileAttr { stat: stat })
|
||||
Ok(FileAttr { stat })
|
||||
}
|
||||
|
||||
pub fn lstat(p: &Path) -> io::Result<FileAttr> {
|
||||
@@ -816,7 +816,7 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
|
||||
cvt(unsafe {
|
||||
lstat64(p.as_ptr(), &mut stat)
|
||||
})?;
|
||||
Ok(FileAttr { stat: stat })
|
||||
Ok(FileAttr { stat })
|
||||
}
|
||||
|
||||
pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
|
||||
|
||||
@@ -217,7 +217,7 @@ mod inner {
|
||||
|
||||
impl From<libc::timespec> for SystemTime {
|
||||
fn from(t: libc::timespec) -> SystemTime {
|
||||
SystemTime { t: Timespec { t: t } }
|
||||
SystemTime { t: Timespec { t } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ mod inner {
|
||||
|
||||
impl From<libc::timespec> for SystemTime {
|
||||
fn from(t: libc::timespec) -> SystemTime {
|
||||
SystemTime { t: Timespec { t: t } }
|
||||
SystemTime { t: Timespec { t } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ impl<'a> DropGuard<'a> {
|
||||
fn new(lock: &'a Mutex) -> DropGuard<'a> {
|
||||
unsafe {
|
||||
lock.lock();
|
||||
DropGuard { lock: lock }
|
||||
DropGuard { lock }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ impl fmt::Debug for SystemTime {
|
||||
|
||||
impl From<c::FILETIME> for SystemTime {
|
||||
fn from(t: c::FILETIME) -> SystemTime {
|
||||
SystemTime { t: t }
|
||||
SystemTime { t }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ impl<T> PoisonError<T> {
|
||||
/// [`RwLock::read`]: ../../std/sync/struct.RwLock.html#method.read
|
||||
#[stable(feature = "sync_poison", since = "1.2.0")]
|
||||
pub fn new(guard: T) -> PoisonError<T> {
|
||||
PoisonError { guard: guard }
|
||||
PoisonError { guard }
|
||||
}
|
||||
|
||||
/// Consumes this error indicating that a lock is poisoned, returning the
|
||||
|
||||
@@ -67,7 +67,7 @@ impl CodePoint {
|
||||
/// Only use when `value` is known to be less than or equal to 0x10FFFF.
|
||||
#[inline]
|
||||
pub unsafe fn from_u32_unchecked(value: u32) -> CodePoint {
|
||||
CodePoint { value: value }
|
||||
CodePoint { value }
|
||||
}
|
||||
|
||||
/// Creates a new `CodePoint` if the value is a valid code point.
|
||||
@@ -76,7 +76,7 @@ impl CodePoint {
|
||||
#[inline]
|
||||
pub fn from_u32(value: u32) -> Option<CodePoint> {
|
||||
match value {
|
||||
0 ..= 0x10FFFF => Some(CodePoint { value: value }),
|
||||
0 ..= 0x10FFFF => Some(CodePoint { value }),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user