diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path.rs | 10 | ||||
| -rw-r--r-- | src/libstd/rand/reader.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/common/backtrace.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process2.rs | 2 |
6 files changed, 11 insertions, 11 deletions
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 6b0546b1ee7..62c03389b24 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -430,7 +430,7 @@ impl<T, S> HashSet<T, S> /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_empty(&self) -> bool { self.map.len() == 0 } + pub fn is_empty(&self) -> bool { self.map.is_empty() } /// Clears the set, returning all elements in an iterator. #[inline] diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 93c6deac6e5..07b43b6c5db 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -349,7 +349,7 @@ pub trait Write { /// This function will return the first error that `write` returns. #[stable(feature = "rust1", since = "1.0.0")] fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { - while buf.len() > 0 { + while !buf.is_empty() { match self.write(buf) { Ok(0) => return Err(Error::new(ErrorKind::WriteZero, "failed to write whole buffer")), diff --git a/src/libstd/path.rs b/src/libstd/path.rs index b7160df6c92..cb78fc56bf2 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -218,7 +218,7 @@ mod platform { return Some(DeviceNS(u8_slice_as_os_str(slice))); } match parse_two_comps(path, is_sep_byte) { - Some((server, share)) if server.len() > 0 && share.len() > 0 => { + Some((server, share)) if !server.is_empty() && !share.is_empty() => { // \\server\share return Some(UNC(u8_slice_as_os_str(server), u8_slice_as_os_str(share))); @@ -401,7 +401,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { /// Says whether the first byte after the prefix is a separator. fn has_physical_root(s: &[u8], prefix: Option<Prefix>) -> bool { let path = if let Some(p) = prefix { &s[p.len()..] } else { s }; - path.len() > 0 && is_sep_byte(path[0]) + !path.is_empty() && is_sep_byte(path[0]) } // basic workhorse for splitting stem and extension @@ -810,7 +810,7 @@ impl<'a> Iterator for Components<'a> { State::StartDir => { self.front = State::Body; if self.has_physical_root { - debug_assert!(self.path.len() > 0); + debug_assert!(!self.path.is_empty()); self.path = &self.path[1..]; return Some(Component::RootDir) } else if let Some(p) = self.prefix { @@ -818,7 +818,7 @@ impl<'a> Iterator for Components<'a> { return Some(Component::RootDir) } } else if self.include_cur_dir() { - debug_assert!(self.path.len() > 0); + debug_assert!(!self.path.is_empty()); self.path = &self.path[1..]; return Some(Component::CurDir) } @@ -1055,7 +1055,7 @@ impl PathBuf { }; let extension = extension.as_ref(); - if os_str_as_u8_slice(extension).len() > 0 { + if !os_str_as_u8_slice(extension).is_empty() { stem.push("."); stem.push(extension); } diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 60645707c6a..f8dd6a00c7f 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -51,7 +51,7 @@ impl<R: Read> Rng for ReaderRng<R> { unsafe { *(bytes.as_ptr() as *const u64) } } fn fill_bytes(&mut self, mut v: &mut [u8]) { - while v.len() > 0 { + while !v.is_empty() { let t = v; match self.reader.read(t) { Ok(0) => panic!("ReaderRng.fill_bytes: EOF reached"), diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index cd118b3c9ee..580d970af0c 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -76,7 +76,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { try!(writer.write_all(s.as_bytes())); } else { let mut first = true; - while inner.len() > 0 { + while !inner.is_empty() { if !first { try!(writer.write_all(b"::")); } else { @@ -89,7 +89,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { let i: usize = inner[.. (inner.len() - rest.len())].parse().unwrap(); inner = &rest[i..]; rest = &rest[..i]; - while rest.len() > 0 { + while !rest.is_empty() { if rest.starts_with("$") { macro_rules! demangle { ($($pat:expr, => $demangled:expr),*) => ({ diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs index fdb47eb8c80..16c2a9125ea 100644 --- a/src/libstd/sys/windows/process2.rs +++ b/src/libstd/sys/windows/process2.rs @@ -381,7 +381,7 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> Vec<u16> { // it will be dropped entirely when parsed on the other end. let arg_bytes = &arg.as_inner().inner.as_inner(); let quote = arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t') - || arg_bytes.len() == 0; + || arg_bytes.is_empty(); if quote { cmd.push('"' as u16); } |
