mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
cleanup: &foo[0..a]
-> &foo[..a]
This commit is contained in:
parent
3a44a19af2
commit
c1d48a8508
@ -1631,7 +1631,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_slice_from() {
|
fn test_slice_from() {
|
||||||
let vec: &[int] = &[1, 2, 3, 4];
|
let vec: &[int] = &[1, 2, 3, 4];
|
||||||
assert_eq!(&vec[0..], vec);
|
assert_eq!(&vec[], vec);
|
||||||
let b: &[int] = &[3, 4];
|
let b: &[int] = &[3, 4];
|
||||||
assert_eq!(&vec[2..], b);
|
assert_eq!(&vec[2..], b);
|
||||||
let b: &[int] = &[];
|
let b: &[int] = &[];
|
||||||
@ -1641,11 +1641,11 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_slice_to() {
|
fn test_slice_to() {
|
||||||
let vec: &[int] = &[1, 2, 3, 4];
|
let vec: &[int] = &[1, 2, 3, 4];
|
||||||
assert_eq!(&vec[0..4], vec);
|
assert_eq!(&vec[..4], vec);
|
||||||
let b: &[int] = &[1, 2];
|
let b: &[int] = &[1, 2];
|
||||||
assert_eq!(&vec[0..2], b);
|
assert_eq!(&vec[..2], b);
|
||||||
let b: &[int] = &[];
|
let b: &[int] = &[];
|
||||||
assert_eq!(&vec[0..0], b);
|
assert_eq!(&vec[..0], b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2538,7 +2538,7 @@ mod tests {
|
|||||||
let (left, right) = values.split_at_mut(2);
|
let (left, right) = values.split_at_mut(2);
|
||||||
{
|
{
|
||||||
let left: &[_] = left;
|
let left: &[_] = left;
|
||||||
assert!(left[0..left.len()] == [1, 2][]);
|
assert!(left[..left.len()] == [1, 2][]);
|
||||||
}
|
}
|
||||||
for p in left.iter_mut() {
|
for p in left.iter_mut() {
|
||||||
*p += 1;
|
*p += 1;
|
||||||
@ -2546,7 +2546,7 @@ mod tests {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let right: &[_] = right;
|
let right: &[_] = right;
|
||||||
assert!(right[0..right.len()] == [3, 4, 5][]);
|
assert!(right[..right.len()] == [3, 4, 5][]);
|
||||||
}
|
}
|
||||||
for p in right.iter_mut() {
|
for p in right.iter_mut() {
|
||||||
*p += 2;
|
*p += 2;
|
||||||
|
@ -807,7 +807,7 @@ pub trait StrExt: Index<FullRange, Output = str> {
|
|||||||
/// out of bounds.
|
/// out of bounds.
|
||||||
///
|
///
|
||||||
/// See also `slice`, `slice_from` and `slice_chars`.
|
/// See also `slice`, `slice_from` and `slice_chars`.
|
||||||
#[unstable = "use slice notation [0..a] instead"]
|
#[unstable = "use slice notation [..a] instead"]
|
||||||
fn slice_to(&self, end: uint) -> &str {
|
fn slice_to(&self, end: uint) -> &str {
|
||||||
core_str::StrExt::slice_to(&self[], end)
|
core_str::StrExt::slice_to(&self[], end)
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ impl String {
|
|||||||
|
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
res.as_mut_vec().push_all(&v[0..i])
|
res.as_mut_vec().push_all(&v[..i])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,5 +332,5 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f(unsafe { str::from_utf8_unchecked(&buf[0..end]) })
|
f(unsafe { str::from_utf8_unchecked(&buf[..end]) })
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ impl<'a> Formatter<'a> {
|
|||||||
for c in sign.into_iter() {
|
for c in sign.into_iter() {
|
||||||
let mut b = [0; 4];
|
let mut b = [0; 4];
|
||||||
let n = c.encode_utf8(&mut b).unwrap_or(0);
|
let n = c.encode_utf8(&mut b).unwrap_or(0);
|
||||||
let b = unsafe { str::from_utf8_unchecked(&b[0..n]) };
|
let b = unsafe { str::from_utf8_unchecked(&b[..n]) };
|
||||||
try!(f.buf.write_str(b));
|
try!(f.buf.write_str(b));
|
||||||
}
|
}
|
||||||
if prefixed { f.buf.write_str(prefix) }
|
if prefixed { f.buf.write_str(prefix) }
|
||||||
@ -692,7 +692,7 @@ impl String for char {
|
|||||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||||
let mut utf8 = [0u8; 4];
|
let mut utf8 = [0u8; 4];
|
||||||
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
|
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
|
||||||
let s: &str = unsafe { mem::transmute(&utf8[0..amt]) };
|
let s: &str = unsafe { mem::transmute(&utf8[..amt]) };
|
||||||
String::fmt(s, f)
|
String::fmt(s, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ impl<T> SliceExt for [T] {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn split_at(&self, mid: uint) -> (&[T], &[T]) {
|
fn split_at(&self, mid: uint) -> (&[T], &[T]) {
|
||||||
(&self[0..mid], &self[mid..])
|
(&self[..mid], &self[mid..])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -240,7 +240,7 @@ impl<T> SliceExt for [T] {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn init(&self) -> &[T] {
|
fn init(&self) -> &[T] {
|
||||||
&self[0..(self.len() - 1)]
|
&self[..(self.len() - 1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -443,7 +443,7 @@ impl<T> SliceExt for [T] {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
|
fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
|
||||||
let n = needle.len();
|
let n = needle.len();
|
||||||
self.len() >= n && needle == &self[0..n]
|
self.len() >= n && needle == &self[..n]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -972,7 +972,7 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
|||||||
match self.v.iter().position(|x| (self.pred)(x)) {
|
match self.v.iter().position(|x| (self.pred)(x)) {
|
||||||
None => self.finish(),
|
None => self.finish(),
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let ret = Some(&self.v[0..idx]);
|
let ret = Some(&self.v[..idx]);
|
||||||
self.v = &self.v[(idx + 1)..];
|
self.v = &self.v[(idx + 1)..];
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@ -999,7 +999,7 @@ impl<'a, T, P> DoubleEndedIterator for Split<'a, T, P> where P: FnMut(&T) -> boo
|
|||||||
None => self.finish(),
|
None => self.finish(),
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let ret = Some(&self.v[(idx + 1)..]);
|
let ret = Some(&self.v[(idx + 1)..]);
|
||||||
self.v = &self.v[0..idx];
|
self.v = &self.v[..idx];
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1195,7 +1195,7 @@ impl<'a, T> Iterator for Windows<'a, T> {
|
|||||||
if self.size > self.v.len() {
|
if self.size > self.v.len() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let ret = Some(&self.v[0..self.size]);
|
let ret = Some(&self.v[..self.size]);
|
||||||
self.v = &self.v[1..];
|
self.v = &self.v[1..];
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
@ -701,10 +701,10 @@ impl TwoWaySearcher {
|
|||||||
//
|
//
|
||||||
// What's going on is we have some critical factorization (u, v) of the
|
// What's going on is we have some critical factorization (u, v) of the
|
||||||
// needle, and we want to determine whether u is a suffix of
|
// needle, and we want to determine whether u is a suffix of
|
||||||
// &v[0..period]. If it is, we use "Algorithm CP1". Otherwise we use
|
// &v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
|
||||||
// "Algorithm CP2", which is optimized for when the period of the needle
|
// "Algorithm CP2", which is optimized for when the period of the needle
|
||||||
// is large.
|
// is large.
|
||||||
if &needle[0..crit_pos] == &needle[period.. period + crit_pos] {
|
if &needle[..crit_pos] == &needle[period.. period + crit_pos] {
|
||||||
TwoWaySearcher {
|
TwoWaySearcher {
|
||||||
crit_pos: crit_pos,
|
crit_pos: crit_pos,
|
||||||
period: period,
|
period: period,
|
||||||
@ -1412,7 +1412,7 @@ impl StrExt for str {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn starts_with(&self, needle: &str) -> bool {
|
fn starts_with(&self, needle: &str) -> bool {
|
||||||
let n = needle.len();
|
let n = needle.len();
|
||||||
self.len() >= n && needle.as_bytes() == &self.as_bytes()[0..n]
|
self.len() >= n && needle.as_bytes() == &self.as_bytes()[..n]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -167,7 +167,7 @@ fn test_encode_utf8() {
|
|||||||
fn check(input: char, expect: &[u8]) {
|
fn check(input: char, expect: &[u8]) {
|
||||||
let mut buf = [0u8; 4];
|
let mut buf = [0u8; 4];
|
||||||
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
||||||
assert_eq!(&buf[0..n], expect);
|
assert_eq!(&buf[..n], expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
check('x', &[0x78]);
|
check('x', &[0x78]);
|
||||||
@ -181,7 +181,7 @@ fn test_encode_utf16() {
|
|||||||
fn check(input: char, expect: &[u16]) {
|
fn check(input: char, expect: &[u16]) {
|
||||||
let mut buf = [0u16; 2];
|
let mut buf = [0u16; 2];
|
||||||
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
|
||||||
assert_eq!(&buf[0..n], expect);
|
assert_eq!(&buf[..n], expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
check('x', &[0x0078]);
|
check('x', &[0x0078]);
|
||||||
|
@ -288,7 +288,7 @@ fn test_iterator_len() {
|
|||||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
assert_eq!(v[..4].iter().count(), 4);
|
assert_eq!(v[..4].iter().count(), 4);
|
||||||
assert_eq!(v[..10].iter().count(), 10);
|
assert_eq!(v[..10].iter().count(), 10);
|
||||||
assert_eq!(v[0..0].iter().count(), 0);
|
assert_eq!(v[..0].iter().count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -296,31 +296,31 @@ fn test_iterator_sum() {
|
|||||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
assert_eq!(v[..4].iter().map(|&x| x).sum(), 6);
|
assert_eq!(v[..4].iter().map(|&x| x).sum(), 6);
|
||||||
assert_eq!(v.iter().map(|&x| x).sum(), 55);
|
assert_eq!(v.iter().map(|&x| x).sum(), 55);
|
||||||
assert_eq!(v[0..0].iter().map(|&x| x).sum(), 0);
|
assert_eq!(v[..0].iter().map(|&x| x).sum(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iterator_product() {
|
fn test_iterator_product() {
|
||||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
assert_eq!(v[0..4].iter().map(|&x| x).product(), 0);
|
assert_eq!(v[..4].iter().map(|&x| x).product(), 0);
|
||||||
assert_eq!(v[1..5].iter().map(|&x| x).product(), 24);
|
assert_eq!(v[1..5].iter().map(|&x| x).product(), 24);
|
||||||
assert_eq!(v[0..0].iter().map(|&x| x).product(), 1);
|
assert_eq!(v[..0].iter().map(|&x| x).product(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iterator_max() {
|
fn test_iterator_max() {
|
||||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
assert_eq!(v[0..4].iter().map(|&x| x).max(), Some(3));
|
assert_eq!(v[..4].iter().map(|&x| x).max(), Some(3));
|
||||||
assert_eq!(v.iter().map(|&x| x).max(), Some(10));
|
assert_eq!(v.iter().map(|&x| x).max(), Some(10));
|
||||||
assert_eq!(v[0..0].iter().map(|&x| x).max(), None);
|
assert_eq!(v[..0].iter().map(|&x| x).max(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iterator_min() {
|
fn test_iterator_min() {
|
||||||
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
assert_eq!(v[0..4].iter().map(|&x| x).min(), Some(0));
|
assert_eq!(v[..4].iter().map(|&x| x).min(), Some(0));
|
||||||
assert_eq!(v.iter().map(|&x| x).min(), Some(0));
|
assert_eq!(v.iter().map(|&x| x).min(), Some(0));
|
||||||
assert_eq!(v[0..0].iter().map(|&x| x).min(), None);
|
assert_eq!(v[..0].iter().map(|&x| x).min(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -373,7 +373,7 @@ fn test_all() {
|
|||||||
assert!(v.iter().all(|&x| x < 10));
|
assert!(v.iter().all(|&x| x < 10));
|
||||||
assert!(!v.iter().all(|&x| x % 2 == 0));
|
assert!(!v.iter().all(|&x| x % 2 == 0));
|
||||||
assert!(!v.iter().all(|&x| x > 100));
|
assert!(!v.iter().all(|&x| x > 100));
|
||||||
assert!(v[0..0].iter().all(|_| panic!()));
|
assert!(v[..0].iter().all(|_| panic!()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -382,7 +382,7 @@ fn test_any() {
|
|||||||
assert!(v.iter().any(|&x| x < 10));
|
assert!(v.iter().any(|&x| x < 10));
|
||||||
assert!(v.iter().any(|&x| x % 2 == 0));
|
assert!(v.iter().any(|&x| x % 2 == 0));
|
||||||
assert!(!v.iter().any(|&x| x > 100));
|
assert!(!v.iter().any(|&x| x > 100));
|
||||||
assert!(!v[0..0].iter().any(|_| panic!()));
|
assert!(!v[..0].iter().any(|_| panic!()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -286,7 +286,7 @@ impl<'a> Parser<'a> {
|
|||||||
flags: 0,
|
flags: 0,
|
||||||
precision: CountImplied,
|
precision: CountImplied,
|
||||||
width: CountImplied,
|
width: CountImplied,
|
||||||
ty: &self.input[0..0],
|
ty: &self.input[..0],
|
||||||
};
|
};
|
||||||
if !self.consume(':') { return spec }
|
if !self.consume(':') { return spec }
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.cur.next();
|
self.cur.next();
|
||||||
pos
|
pos
|
||||||
}
|
}
|
||||||
Some(..) | None => { return &self.input[0..0]; }
|
Some(..) | None => { return &self.input[..0]; }
|
||||||
};
|
};
|
||||||
let mut end;
|
let mut end;
|
||||||
loop {
|
loop {
|
||||||
|
@ -270,8 +270,7 @@ pub trait Rng : Sized {
|
|||||||
/// let choices = [1i, 2, 4, 8, 16, 32];
|
/// let choices = [1i, 2, 4, 8, 16, 32];
|
||||||
/// let mut rng = thread_rng();
|
/// let mut rng = thread_rng();
|
||||||
/// println!("{:?}", rng.choose(&choices));
|
/// println!("{:?}", rng.choose(&choices));
|
||||||
/// # // uncomment when slicing syntax is stable
|
/// assert_eq!(rng.choose(&choices[..0]), None);
|
||||||
/// //assert_eq!(rng.choose(&choices[0..0]), None);
|
|
||||||
/// ```
|
/// ```
|
||||||
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
|
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
|
||||||
if values.is_empty() {
|
if values.is_empty() {
|
||||||
|
@ -95,7 +95,7 @@ impl Writer for SeekableMemWriter {
|
|||||||
// there (left), and what will be appended on the end (right)
|
// there (left), and what will be appended on the end (right)
|
||||||
let cap = self.buf.len() - self.pos;
|
let cap = self.buf.len() - self.pos;
|
||||||
let (left, right) = if cap <= buf.len() {
|
let (left, right) = if cap <= buf.len() {
|
||||||
(&buf[0..cap], &buf[cap..])
|
(&buf[..cap], &buf[cap..])
|
||||||
} else {
|
} else {
|
||||||
let result: (_, &[_]) = (buf, &[]);
|
let result: (_, &[_]) = (buf, &[]);
|
||||||
result
|
result
|
||||||
|
@ -926,7 +926,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
head.map(|mut head| {
|
head.map(|mut head| {
|
||||||
head.push_all(&r[0..col]);
|
head.push_all(&r[..col]);
|
||||||
head.push_all(&r[(col + 1)..]);
|
head.push_all(&r[(col + 1)..]);
|
||||||
head
|
head
|
||||||
})
|
})
|
||||||
|
@ -542,7 +542,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
for t in tps[0..(tps.len() - num_defaults)].iter() {
|
for t in tps[..(tps.len() - num_defaults)].iter() {
|
||||||
strs.push(ty_to_string(cx, *t))
|
strs.push(ty_to_string(cx, *t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||||||
if input.len() >= buffer_remaining {
|
if input.len() >= buffer_remaining {
|
||||||
copy_memory(
|
copy_memory(
|
||||||
self.buffer.slice_mut(self.buffer_idx, size),
|
self.buffer.slice_mut(self.buffer_idx, size),
|
||||||
&input[0..buffer_remaining]);
|
&input[..buffer_remaining]);
|
||||||
self.buffer_idx = 0;
|
self.buffer_idx = 0;
|
||||||
func(&self.buffer);
|
func(&self.buffer);
|
||||||
i += buffer_remaining;
|
i += buffer_remaining;
|
||||||
@ -188,7 +188,7 @@ impl FixedBuffer for FixedBuffer64 {
|
|||||||
fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
|
fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
|
||||||
assert!(self.buffer_idx == 64);
|
assert!(self.buffer_idx == 64);
|
||||||
self.buffer_idx = 0;
|
self.buffer_idx = 0;
|
||||||
return &self.buffer[0..64];
|
return &self.buffer[..64];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn position(&self) -> uint { self.buffer_idx }
|
fn position(&self) -> uint { self.buffer_idx }
|
||||||
|
@ -2081,7 +2081,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
// idx +- 1 to account for the
|
// idx +- 1 to account for the
|
||||||
// colons on either side
|
// colons on either side
|
||||||
&mpath[(idx + 1)..],
|
&mpath[(idx + 1)..],
|
||||||
&mpath[0..(idx - 1)]);
|
&mpath[..(idx - 1)]);
|
||||||
return Failed(Some((span, msg)));
|
return Failed(Some((span, msg)));
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
@ -186,7 +186,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
|||||||
fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
|
fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
|
||||||
let magic_id_byte_count = link::RLIB_BYTECODE_OBJECT_MAGIC.len();
|
let magic_id_byte_count = link::RLIB_BYTECODE_OBJECT_MAGIC.len();
|
||||||
return bc.len() > magic_id_byte_count &&
|
return bc.len() > magic_id_byte_count &&
|
||||||
&bc[0..magic_id_byte_count] == link::RLIB_BYTECODE_OBJECT_MAGIC;
|
&bc[..magic_id_byte_count] == link::RLIB_BYTECODE_OBJECT_MAGIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_bytecode_format_version(bc: &[u8]) -> u32 {
|
fn extract_bytecode_format_version(bc: &[u8]) -> u32 {
|
||||||
|
@ -186,7 +186,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||||||
if len <= 2 {
|
if len <= 2 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sub_paths = &sub_paths[0..(len-2)];
|
let sub_paths = &sub_paths[..(len-2)];
|
||||||
for &(ref span, ref qualname) in sub_paths.iter() {
|
for &(ref span, ref qualname) in sub_paths.iter() {
|
||||||
self.fmt.sub_mod_ref_str(path.span,
|
self.fmt.sub_mod_ref_str(path.span,
|
||||||
*span,
|
*span,
|
||||||
|
@ -166,7 +166,7 @@ impl<'a> FmtStrs<'a> {
|
|||||||
let values = values.iter().map(|s| {
|
let values = values.iter().map(|s| {
|
||||||
// Never take more than 1020 chars
|
// Never take more than 1020 chars
|
||||||
if s.len() > 1020 {
|
if s.len() > 1020 {
|
||||||
&s[0..1020]
|
&s[..1020]
|
||||||
} else {
|
} else {
|
||||||
&s[]
|
&s[]
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
// Collect all of the matches that can match against anything.
|
// Collect all of the matches that can match against anything.
|
||||||
enter_match(bcx, dm, m, col, val, |pats| {
|
enter_match(bcx, dm, m, col, val, |pats| {
|
||||||
if pat_is_binding_or_wild(dm, &*pats[col]) {
|
if pat_is_binding_or_wild(dm, &*pats[col]) {
|
||||||
let mut r = pats[0..col].to_vec();
|
let mut r = pats[..col].to_vec();
|
||||||
r.push_all(&pats[(col + 1)..]);
|
r.push_all(&pats[(col + 1)..]);
|
||||||
Some(r)
|
Some(r)
|
||||||
} else {
|
} else {
|
||||||
|
@ -552,7 +552,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
|
for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
|
||||||
*small_vec_e = C_i32(self.ccx, ix as i32);
|
*small_vec_e = C_i32(self.ccx, ix as i32);
|
||||||
}
|
}
|
||||||
self.inbounds_gep(base, &small_vec[0..ixs.len()])
|
self.inbounds_gep(base, &small_vec[..ixs.len()])
|
||||||
} else {
|
} else {
|
||||||
let v = ixs.iter().map(|i| C_i32(self.ccx, *i as i32)).collect::<Vec<ValueRef>>();
|
let v = ixs.iter().map(|i| C_i32(self.ccx, *i as i32)).collect::<Vec<ValueRef>>();
|
||||||
self.count_insn("gepi");
|
self.count_insn("gepi");
|
||||||
|
@ -962,7 +962,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
let variable_access = IndirectVariable {
|
let variable_access = IndirectVariable {
|
||||||
alloca: env_pointer,
|
alloca: env_pointer,
|
||||||
address_operations: &address_operations[0..address_op_count]
|
address_operations: &address_operations[..address_op_count]
|
||||||
};
|
};
|
||||||
|
|
||||||
declare_local(bcx,
|
declare_local(bcx,
|
||||||
|
@ -332,7 +332,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
|
|||||||
match rel_root {
|
match rel_root {
|
||||||
Some(root) => {
|
Some(root) => {
|
||||||
let mut root = String::from_str(root.as_slice());
|
let mut root = String::from_str(root.as_slice());
|
||||||
for seg in path.segments[0..amt].iter() {
|
for seg in path.segments[..amt].iter() {
|
||||||
if "super" == seg.name ||
|
if "super" == seg.name ||
|
||||||
"self" == seg.name {
|
"self" == seg.name {
|
||||||
try!(write!(w, "{}::", seg.name));
|
try!(write!(w, "{}::", seg.name));
|
||||||
@ -347,7 +347,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
for seg in path.segments[0..amt].iter() {
|
for seg in path.segments[..amt].iter() {
|
||||||
try!(write!(w, "{}::", seg.name));
|
try!(write!(w, "{}::", seg.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
|
|||||||
fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result {
|
fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result {
|
||||||
let mut buf = [0; 4];
|
let mut buf = [0; 4];
|
||||||
let n = v.encode_utf8(&mut buf).unwrap();
|
let n = v.encode_utf8(&mut buf).unwrap();
|
||||||
let buf = unsafe { str::from_utf8_unchecked(&buf[0..n]) };
|
let buf = unsafe { str::from_utf8_unchecked(&buf[..n]) };
|
||||||
escape_str(writer, buf)
|
escape_str(writer, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ fn spaces(wr: &mut fmt::Writer, mut n: uint) -> fmt::Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
wr.write_str(&BUF[0..n])
|
wr.write_str(&BUF[..n])
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ impl<R: Reader> Reader for BufferedReader<R> {
|
|||||||
let nread = {
|
let nread = {
|
||||||
let available = try!(self.fill_buf());
|
let available = try!(self.fill_buf());
|
||||||
let nread = cmp::min(available.len(), buf.len());
|
let nread = cmp::min(available.len(), buf.len());
|
||||||
slice::bytes::copy_memory(buf, &available[0..nread]);
|
slice::bytes::copy_memory(buf, &available[..nread]);
|
||||||
nread
|
nread
|
||||||
};
|
};
|
||||||
self.pos += nread;
|
self.pos += nread;
|
||||||
@ -183,7 +183,7 @@ impl<W: Writer> BufferedWriter<W> {
|
|||||||
|
|
||||||
fn flush_buf(&mut self) -> IoResult<()> {
|
fn flush_buf(&mut self) -> IoResult<()> {
|
||||||
if self.pos != 0 {
|
if self.pos != 0 {
|
||||||
let ret = self.inner.as_mut().unwrap().write(&self.buf[0..self.pos]);
|
let ret = self.inner.as_mut().unwrap().write(&self.buf[..self.pos]);
|
||||||
self.pos = 0;
|
self.pos = 0;
|
||||||
ret
|
ret
|
||||||
} else {
|
} else {
|
||||||
@ -282,7 +282,7 @@ impl<W: Writer> Writer for LineBufferedWriter<W> {
|
|||||||
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
||||||
match buf.iter().rposition(|&b| b == b'\n') {
|
match buf.iter().rposition(|&b| b == b'\n') {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
try!(self.inner.write(&buf[0..(i + 1)]));
|
try!(self.inner.write(&buf[..(i + 1)]));
|
||||||
try!(self.inner.flush());
|
try!(self.inner.flush());
|
||||||
try!(self.inner.write(&buf[(i + 1)..]));
|
try!(self.inner.write(&buf[(i + 1)..]));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -90,7 +90,7 @@ impl Reader for ChanReader {
|
|||||||
Some(src) => {
|
Some(src) => {
|
||||||
let dst = buf.slice_from_mut(num_read);
|
let dst = buf.slice_from_mut(num_read);
|
||||||
let count = cmp::min(src.len(), dst.len());
|
let count = cmp::min(src.len(), dst.len());
|
||||||
bytes::copy_memory(dst, &src[0..count]);
|
bytes::copy_memory(dst, &src[..count]);
|
||||||
count
|
count
|
||||||
},
|
},
|
||||||
None => 0,
|
None => 0,
|
||||||
|
@ -889,7 +889,7 @@ mod test {
|
|||||||
let mut read_buf = [0; 1028];
|
let mut read_buf = [0; 1028];
|
||||||
let read_str = match check!(read_stream.read(&mut read_buf)) {
|
let read_str = match check!(read_stream.read(&mut read_buf)) {
|
||||||
-1|0 => panic!("shouldn't happen"),
|
-1|0 => panic!("shouldn't happen"),
|
||||||
n => str::from_utf8(&read_buf[0..n]).unwrap().to_string()
|
n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
|
||||||
};
|
};
|
||||||
assert_eq!(read_str.as_slice(), message);
|
assert_eq!(read_str.as_slice(), message);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ impl<'a> Reader for &'a [u8] {
|
|||||||
|
|
||||||
let write_len = min(buf.len(), self.len());
|
let write_len = min(buf.len(), self.len());
|
||||||
{
|
{
|
||||||
let input = &self[0..write_len];
|
let input = &self[..write_len];
|
||||||
let output = buf.slice_to_mut(write_len);
|
let output = buf.slice_to_mut(write_len);
|
||||||
slice::bytes::copy_memory(output, input);
|
slice::bytes::copy_memory(output, input);
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ impl<'a> Writer for BufWriter<'a> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
slice::bytes::copy_memory(dst, &src[0..dst_len]);
|
slice::bytes::copy_memory(dst, &src[..dst_len]);
|
||||||
|
|
||||||
self.pos += dst_len;
|
self.pos += dst_len;
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ mod test {
|
|||||||
assert_eq!(buf, b);
|
assert_eq!(buf, b);
|
||||||
assert_eq!(reader.read(&mut buf), Ok(3));
|
assert_eq!(reader.read(&mut buf), Ok(3));
|
||||||
let b: &[_] = &[5, 6, 7];
|
let b: &[_] = &[5, 6, 7];
|
||||||
assert_eq!(&buf[0..3], b);
|
assert_eq!(&buf[..3], b);
|
||||||
assert!(reader.read(&mut buf).is_err());
|
assert!(reader.read(&mut buf).is_err());
|
||||||
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
|
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
|
||||||
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
||||||
@ -524,7 +524,7 @@ mod test {
|
|||||||
assert_eq!(buf.as_slice(), b);
|
assert_eq!(buf.as_slice(), b);
|
||||||
assert_eq!(reader.read(&mut buf), Ok(3));
|
assert_eq!(reader.read(&mut buf), Ok(3));
|
||||||
let b: &[_] = &[5, 6, 7];
|
let b: &[_] = &[5, 6, 7];
|
||||||
assert_eq!(&buf[0..3], b);
|
assert_eq!(&buf[..3], b);
|
||||||
assert!(reader.read(&mut buf).is_err());
|
assert!(reader.read(&mut buf).is_err());
|
||||||
let mut reader = &mut in_buf.as_slice();
|
let mut reader = &mut in_buf.as_slice();
|
||||||
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
||||||
@ -551,7 +551,7 @@ mod test {
|
|||||||
assert_eq!(buf, b);
|
assert_eq!(buf, b);
|
||||||
assert_eq!(reader.read(&mut buf), Ok(3));
|
assert_eq!(reader.read(&mut buf), Ok(3));
|
||||||
let b: &[_] = &[5, 6, 7];
|
let b: &[_] = &[5, 6, 7];
|
||||||
assert_eq!(&buf[0..3], b);
|
assert_eq!(&buf[..3], b);
|
||||||
assert!(reader.read(&mut buf).is_err());
|
assert!(reader.read(&mut buf).is_err());
|
||||||
let mut reader = BufReader::new(in_buf.as_slice());
|
let mut reader = BufReader::new(in_buf.as_slice());
|
||||||
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
|
||||||
|
@ -1069,7 +1069,7 @@ pub trait Writer {
|
|||||||
fn write_char(&mut self, c: char) -> IoResult<()> {
|
fn write_char(&mut self, c: char) -> IoResult<()> {
|
||||||
let mut buf = [0u8; 4];
|
let mut buf = [0u8; 4];
|
||||||
let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
|
||||||
self.write(&buf[0..n])
|
self.write(&buf[..n])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write the result of passing n through `int::to_str_bytes`.
|
/// Write the result of passing n through `int::to_str_bytes`.
|
||||||
@ -1454,7 +1454,7 @@ pub trait Buffer: Reader {
|
|||||||
};
|
};
|
||||||
match available.iter().position(|&b| b == byte) {
|
match available.iter().position(|&b| b == byte) {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
res.push_all(&available[0..(i + 1)]);
|
res.push_all(&available[..(i + 1)]);
|
||||||
used = i + 1;
|
used = i + 1;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1493,7 +1493,7 @@ pub trait Buffer: Reader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match str::from_utf8(&buf[0..width]).ok() {
|
match str::from_utf8(&buf[..width]).ok() {
|
||||||
Some(s) => Ok(s.char_at(0)),
|
Some(s) => Ok(s.char_at(0)),
|
||||||
None => Err(standard_error(InvalidInput))
|
None => Err(standard_error(InvalidInput))
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
let mut tail = [0u16; 8];
|
let mut tail = [0u16; 8];
|
||||||
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
|
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
|
||||||
Some(ipv6_addr_from_head_tail(&head[0..head_size], &tail[0..tail_size]))
|
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
|
fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
|
||||||
|
@ -60,7 +60,7 @@ impl<R: Reader> Reader for LimitReader<R> {
|
|||||||
impl<R: Buffer> Buffer for LimitReader<R> {
|
impl<R: Buffer> Buffer for LimitReader<R> {
|
||||||
fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
|
fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
|
||||||
let amt = try!(self.inner.fill_buf());
|
let amt = try!(self.inner.fill_buf());
|
||||||
let buf = &amt[0..cmp::min(amt.len(), self.limit)];
|
let buf = &amt[..cmp::min(amt.len(), self.limit)];
|
||||||
if buf.len() == 0 {
|
if buf.len() == 0 {
|
||||||
Err(io::standard_error(io::EndOfFile))
|
Err(io::standard_error(io::EndOfFile))
|
||||||
} else {
|
} else {
|
||||||
@ -223,7 +223,7 @@ impl<R: Reader, W: Writer> TeeReader<R, W> {
|
|||||||
impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
|
impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
|
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
|
||||||
self.reader.read(buf).and_then(|len| {
|
self.reader.read(buf).and_then(|len| {
|
||||||
self.writer.write(&mut buf[0..len]).map(|()| len)
|
self.writer.write(&mut buf[..len]).map(|()| len)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> {
|
|||||||
Err(ref e) if e.kind == io::EndOfFile => return Ok(()),
|
Err(ref e) if e.kind == io::EndOfFile => return Ok(()),
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
try!(w.write(&buf[0..len]));
|
try!(w.write(&buf[..len]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
|||||||
match name.rposition_elem(&dot) {
|
match name.rposition_elem(&dot) {
|
||||||
None | Some(0) => name,
|
None | Some(0) => name,
|
||||||
Some(1) if name == b".." => name,
|
Some(1) if name == b".." => name,
|
||||||
Some(pos) => &name[0..pos]
|
Some(pos) => &name[..pos]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
|||||||
let extlen = extension.container_as_bytes().len();
|
let extlen = extension.container_as_bytes().len();
|
||||||
match (name.rposition_elem(&dot), extlen) {
|
match (name.rposition_elem(&dot), extlen) {
|
||||||
(None, 0) | (Some(0), 0) => None,
|
(None, 0) | (Some(0), 0) => None,
|
||||||
(Some(idx), 0) => Some(name[0..idx].to_vec()),
|
(Some(idx), 0) => Some(name[..idx].to_vec()),
|
||||||
(idx, extlen) => {
|
(idx, extlen) => {
|
||||||
let idx = match idx {
|
let idx = match idx {
|
||||||
None | Some(0) => name.len(),
|
None | Some(0) => name.len(),
|
||||||
@ -484,7 +484,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
|||||||
|
|
||||||
let mut v;
|
let mut v;
|
||||||
v = Vec::with_capacity(idx + extlen + 1);
|
v = Vec::with_capacity(idx + extlen + 1);
|
||||||
v.push_all(&name[0..idx]);
|
v.push_all(&name[..idx]);
|
||||||
v.push(dot);
|
v.push(dot);
|
||||||
v.push_all(extension.container_as_bytes());
|
v.push_all(extension.container_as_bytes());
|
||||||
Some(v)
|
Some(v)
|
||||||
|
@ -136,7 +136,7 @@ impl GenericPathUnsafe for Path {
|
|||||||
}
|
}
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
let mut v = Vec::with_capacity(idx + 1 + filename.len());
|
let mut v = Vec::with_capacity(idx + 1 + filename.len());
|
||||||
v.push_all(&self.repr[0..(idx+1)]);
|
v.push_all(&self.repr[..(idx+1)]);
|
||||||
v.push_all(filename);
|
v.push_all(filename);
|
||||||
// FIXME: this is slow
|
// FIXME: this is slow
|
||||||
self.repr = Path::normalize(v.as_slice());
|
self.repr = Path::normalize(v.as_slice());
|
||||||
@ -177,9 +177,9 @@ impl GenericPath for Path {
|
|||||||
match self.sepidx {
|
match self.sepidx {
|
||||||
None if b".." == self.repr => self.repr.as_slice(),
|
None if b".." == self.repr => self.repr.as_slice(),
|
||||||
None => dot_static,
|
None => dot_static,
|
||||||
Some(0) => &self.repr[0..1],
|
Some(0) => &self.repr[..1],
|
||||||
Some(idx) if &self.repr[(idx+1)..] == b".." => self.repr.as_slice(),
|
Some(idx) if &self.repr[(idx+1)..] == b".." => self.repr.as_slice(),
|
||||||
Some(idx) => &self.repr[0..idx]
|
Some(idx) => &self.repr[..idx]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,20 +180,20 @@ impl GenericPathUnsafe for Path {
|
|||||||
}
|
}
|
||||||
Some((_,idxa,end)) if &self.repr[idxa..end] == ".." => {
|
Some((_,idxa,end)) if &self.repr[idxa..end] == ".." => {
|
||||||
let mut s = String::with_capacity(end + 1 + filename.len());
|
let mut s = String::with_capacity(end + 1 + filename.len());
|
||||||
s.push_str(&self.repr[0..end]);
|
s.push_str(&self.repr[..end]);
|
||||||
s.push(SEP);
|
s.push(SEP);
|
||||||
s.push_str(filename);
|
s.push_str(filename);
|
||||||
self.update_normalized(&s[]);
|
self.update_normalized(&s[]);
|
||||||
}
|
}
|
||||||
Some((idxb,idxa,_)) if self.prefix == Some(DiskPrefix) && idxa == self.prefix_len() => {
|
Some((idxb,idxa,_)) if self.prefix == Some(DiskPrefix) && idxa == self.prefix_len() => {
|
||||||
let mut s = String::with_capacity(idxb + filename.len());
|
let mut s = String::with_capacity(idxb + filename.len());
|
||||||
s.push_str(&self.repr[0..idxb]);
|
s.push_str(&self.repr[..idxb]);
|
||||||
s.push_str(filename);
|
s.push_str(filename);
|
||||||
self.update_normalized(&s[]);
|
self.update_normalized(&s[]);
|
||||||
}
|
}
|
||||||
Some((idxb,_,_)) => {
|
Some((idxb,_,_)) => {
|
||||||
let mut s = String::with_capacity(idxb + 1 + filename.len());
|
let mut s = String::with_capacity(idxb + 1 + filename.len());
|
||||||
s.push_str(&self.repr[0..idxb]);
|
s.push_str(&self.repr[..idxb]);
|
||||||
s.push(SEP);
|
s.push(SEP);
|
||||||
s.push_str(filename);
|
s.push_str(filename);
|
||||||
self.update_normalized(&s[]);
|
self.update_normalized(&s[]);
|
||||||
@ -350,13 +350,13 @@ impl GenericPath for Path {
|
|||||||
Some((idxb,_,end)) if &self.repr[idxb..end] == "\\" => {
|
Some((idxb,_,end)) if &self.repr[idxb..end] == "\\" => {
|
||||||
&self.repr[]
|
&self.repr[]
|
||||||
}
|
}
|
||||||
Some((0,idxa,_)) => &self.repr[0..idxa],
|
Some((0,idxa,_)) => &self.repr[..idxa],
|
||||||
Some((idxb,idxa,_)) => {
|
Some((idxb,idxa,_)) => {
|
||||||
match self.prefix {
|
match self.prefix {
|
||||||
Some(DiskPrefix) | Some(VerbatimDiskPrefix) if idxb == self.prefix_len() => {
|
Some(DiskPrefix) | Some(VerbatimDiskPrefix) if idxb == self.prefix_len() => {
|
||||||
&self.repr[0..idxa]
|
&self.repr[..idxa]
|
||||||
}
|
}
|
||||||
_ => &self.repr[0..idxb]
|
_ => &self.repr[..idxb]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -428,15 +428,15 @@ impl GenericPath for Path {
|
|||||||
if self.prefix.is_some() {
|
if self.prefix.is_some() {
|
||||||
Some(Path::new(match self.prefix {
|
Some(Path::new(match self.prefix {
|
||||||
Some(DiskPrefix) if self.is_absolute() => {
|
Some(DiskPrefix) if self.is_absolute() => {
|
||||||
&self.repr[0..(self.prefix_len()+1)]
|
&self.repr[..(self.prefix_len()+1)]
|
||||||
}
|
}
|
||||||
Some(VerbatimDiskPrefix) => {
|
Some(VerbatimDiskPrefix) => {
|
||||||
&self.repr[0..(self.prefix_len()+1)]
|
&self.repr[..(self.prefix_len()+1)]
|
||||||
}
|
}
|
||||||
_ => &self.repr[0..self.prefix_len()]
|
_ => &self.repr[..self.prefix_len()]
|
||||||
}))
|
}))
|
||||||
} else if is_vol_relative(self) {
|
} else if is_vol_relative(self) {
|
||||||
Some(Path::new(&self.repr[0..1]))
|
Some(Path::new(&self.repr[..1]))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -683,7 +683,7 @@ impl Path {
|
|||||||
}
|
}
|
||||||
(None, None) => true,
|
(None, None) => true,
|
||||||
(a, b) if a == b => {
|
(a, b) if a == b => {
|
||||||
&s_repr[0..self.prefix_len()] == &o_repr[0..other.prefix_len()]
|
&s_repr[..self.prefix_len()] == &o_repr[..other.prefix_len()]
|
||||||
}
|
}
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
@ -737,7 +737,7 @@ impl Path {
|
|||||||
match prefix.unwrap() {
|
match prefix.unwrap() {
|
||||||
DiskPrefix => {
|
DiskPrefix => {
|
||||||
let len = prefix_len(prefix) + is_abs as uint;
|
let len = prefix_len(prefix) + is_abs as uint;
|
||||||
let mut s = String::from_str(&s[0..len]);
|
let mut s = String::from_str(&s[..len]);
|
||||||
unsafe {
|
unsafe {
|
||||||
let v = s.as_mut_vec();
|
let v = s.as_mut_vec();
|
||||||
v[0] = (*v)[0].to_ascii_uppercase();
|
v[0] = (*v)[0].to_ascii_uppercase();
|
||||||
@ -752,7 +752,7 @@ impl Path {
|
|||||||
}
|
}
|
||||||
VerbatimDiskPrefix => {
|
VerbatimDiskPrefix => {
|
||||||
let len = prefix_len(prefix) + is_abs as uint;
|
let len = prefix_len(prefix) + is_abs as uint;
|
||||||
let mut s = String::from_str(&s[0..len]);
|
let mut s = String::from_str(&s[..len]);
|
||||||
unsafe {
|
unsafe {
|
||||||
let v = s.as_mut_vec();
|
let v = s.as_mut_vec();
|
||||||
v[4] = (*v)[4].to_ascii_uppercase();
|
v[4] = (*v)[4].to_ascii_uppercase();
|
||||||
@ -762,14 +762,14 @@ impl Path {
|
|||||||
_ => {
|
_ => {
|
||||||
let plen = prefix_len(prefix);
|
let plen = prefix_len(prefix);
|
||||||
if s.len() > plen {
|
if s.len() > plen {
|
||||||
Some(String::from_str(&s[0..plen]))
|
Some(String::from_str(&s[..plen]))
|
||||||
} else { None }
|
} else { None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if is_abs && comps.is_empty() {
|
} else if is_abs && comps.is_empty() {
|
||||||
Some(repeat(SEP).take(1).collect())
|
Some(repeat(SEP).take(1).collect())
|
||||||
} else {
|
} else {
|
||||||
let prefix_ = &s[0..prefix_len(prefix)];
|
let prefix_ = &s[..prefix_len(prefix)];
|
||||||
let n = prefix_.len() +
|
let n = prefix_.len() +
|
||||||
if is_abs { comps.len() } else { comps.len() - 1} +
|
if is_abs { comps.len() } else { comps.len() - 1} +
|
||||||
comps.iter().map(|v| v.len()).sum();
|
comps.iter().map(|v| v.len()).sum();
|
||||||
@ -780,7 +780,7 @@ impl Path {
|
|||||||
s.push(':');
|
s.push(':');
|
||||||
}
|
}
|
||||||
Some(VerbatimDiskPrefix) => {
|
Some(VerbatimDiskPrefix) => {
|
||||||
s.push_str(&prefix_[0..4]);
|
s.push_str(&prefix_[..4]);
|
||||||
s.push(prefix_.as_bytes()[4].to_ascii_uppercase() as char);
|
s.push(prefix_.as_bytes()[4].to_ascii_uppercase() as char);
|
||||||
s.push_str(&prefix_[5..]);
|
s.push_str(&prefix_[5..]);
|
||||||
}
|
}
|
||||||
@ -813,7 +813,7 @@ impl Path {
|
|||||||
|
|
||||||
fn update_sepidx(&mut self) {
|
fn update_sepidx(&mut self) {
|
||||||
let s = if self.has_nonsemantic_trailing_slash() {
|
let s = if self.has_nonsemantic_trailing_slash() {
|
||||||
&self.repr[0..(self.repr.len()-1)]
|
&self.repr[..(self.repr.len()-1)]
|
||||||
} else { &self.repr[] };
|
} else { &self.repr[] };
|
||||||
let sep_test: fn(char) -> bool = if !prefix_is_verbatim(self.prefix) {
|
let sep_test: fn(char) -> bool = if !prefix_is_verbatim(self.prefix) {
|
||||||
is_sep
|
is_sep
|
||||||
|
@ -544,7 +544,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
|
|||||||
// MAX_CALLBACKS, so we're sure to clamp it as necessary.
|
// MAX_CALLBACKS, so we're sure to clamp it as necessary.
|
||||||
let callbacks = {
|
let callbacks = {
|
||||||
let amt = CALLBACK_CNT.load(Ordering::SeqCst);
|
let amt = CALLBACK_CNT.load(Ordering::SeqCst);
|
||||||
&CALLBACKS[0..cmp::min(amt, MAX_CALLBACKS)]
|
&CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
|
||||||
};
|
};
|
||||||
for cb in callbacks.iter() {
|
for cb in callbacks.iter() {
|
||||||
match cb.load(Ordering::SeqCst) {
|
match cb.load(Ordering::SeqCst) {
|
||||||
|
@ -131,7 +131,7 @@ pub fn abort(args: fmt::Arguments) -> ! {
|
|||||||
impl<'a> fmt::Writer for BufWriter<'a> {
|
impl<'a> fmt::Writer for BufWriter<'a> {
|
||||||
fn write_str(&mut self, bytes: &str) -> fmt::Result {
|
fn write_str(&mut self, bytes: &str) -> fmt::Result {
|
||||||
let left = self.buf.slice_from_mut(self.pos);
|
let left = self.buf.slice_from_mut(self.pos);
|
||||||
let to_write = &bytes.as_bytes()[0..cmp::min(bytes.len(), left.len())];
|
let to_write = &bytes.as_bytes()[..cmp::min(bytes.len(), left.len())];
|
||||||
slice::bytes::copy_memory(left, to_write);
|
slice::bytes::copy_memory(left, to_write);
|
||||||
self.pos += to_write.len();
|
self.pos += to_write.len();
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -142,7 +142,7 @@ pub fn abort(args: fmt::Arguments) -> ! {
|
|||||||
let mut msg = [0u8; 512];
|
let mut msg = [0u8; 512];
|
||||||
let mut w = BufWriter { buf: &mut msg, pos: 0 };
|
let mut w = BufWriter { buf: &mut msg, pos: 0 };
|
||||||
let _ = write!(&mut w, "{}", args);
|
let _ = write!(&mut w, "{}", args);
|
||||||
let msg = str::from_utf8(&w.buf[0..w.pos]).unwrap_or("aborted");
|
let msg = str::from_utf8(&w.buf[..w.pos]).unwrap_or("aborted");
|
||||||
let msg = if msg.is_empty() {"aborted"} else {msg};
|
let msg = if msg.is_empty() {"aborted"} else {msg};
|
||||||
|
|
||||||
// Give some context to the message
|
// Give some context to the message
|
||||||
|
@ -36,7 +36,7 @@ const BUF_BYTES : uint = 2048u;
|
|||||||
pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
|
pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
|
||||||
match v.iter().position(|c| *c == 0) {
|
match v.iter().position(|c| *c == 0) {
|
||||||
// don't include the 0
|
// don't include the 0
|
||||||
Some(i) => &v[0..i],
|
Some(i) => &v[..i],
|
||||||
None => v
|
None => v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ impl<'ast> Map<'ast> {
|
|||||||
NodesMatchingSuffix {
|
NodesMatchingSuffix {
|
||||||
map: self,
|
map: self,
|
||||||
item_name: parts.last().unwrap(),
|
item_name: parts.last().unwrap(),
|
||||||
in_which: &parts[0..(parts.len() - 1)],
|
in_which: &parts[..(parts.len() - 1)],
|
||||||
idx: 0,
|
idx: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ impl FileMap {
|
|||||||
let begin = begin.to_uint();
|
let begin = begin.to_uint();
|
||||||
let slice = &self.src[begin..];
|
let slice = &self.src[begin..];
|
||||||
match slice.find('\n') {
|
match slice.find('\n') {
|
||||||
Some(e) => &slice[0..e],
|
Some(e) => &slice[..e],
|
||||||
None => slice
|
None => slice
|
||||||
}.to_string()
|
}.to_string()
|
||||||
})
|
})
|
||||||
|
@ -277,7 +277,7 @@ fn print_maybe_styled(w: &mut EmitterWriter,
|
|||||||
// to be miscolored. We assume this is rare enough that we don't
|
// to be miscolored. We assume this is rare enough that we don't
|
||||||
// have to worry about it.
|
// have to worry about it.
|
||||||
if msg.ends_with("\n") {
|
if msg.ends_with("\n") {
|
||||||
try!(t.write_str(&msg[0..(msg.len()-1)]));
|
try!(t.write_str(&msg[..(msg.len()-1)]));
|
||||||
try!(t.reset());
|
try!(t.reset());
|
||||||
try!(t.write_str("\n"));
|
try!(t.write_str("\n"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -128,7 +128,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> {
|
|||||||
copy_memory(buf.as_mut_slice(), alu);
|
copy_memory(buf.as_mut_slice(), alu);
|
||||||
let buf_len = buf.len();
|
let buf_len = buf.len();
|
||||||
copy_memory(buf.slice_mut(alu_len, buf_len),
|
copy_memory(buf.slice_mut(alu_len, buf_len),
|
||||||
&alu[0..LINE_LEN]);
|
&alu[..LINE_LEN]);
|
||||||
|
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
let mut bytes;
|
let mut bytes;
|
||||||
@ -204,7 +204,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
|
|||||||
for i in range(0u, chars_left) {
|
for i in range(0u, chars_left) {
|
||||||
buf[i] = self.nextc();
|
buf[i] = self.nextc();
|
||||||
}
|
}
|
||||||
self.out.write(&buf[0..chars_left])
|
self.out.write(&buf[..chars_left])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ fn main() {
|
|||||||
let ss: &&[int] = &s;
|
let ss: &&[int] = &s;
|
||||||
let sss: &&&[int] = &ss;
|
let sss: &&&[int] = &ss;
|
||||||
|
|
||||||
println!("{:?}", &s[0..3]);
|
println!("{:?}", &s[..3]);
|
||||||
println!("{:?}", &ss[3..]);
|
println!("{:?}", &ss[3..]);
|
||||||
println!("{:?}", &sss[2..4]);
|
println!("{:?}", &sss[2..4]);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ pub fn main() {
|
|||||||
let abc = [1i, 2, 3];
|
let abc = [1i, 2, 3];
|
||||||
let tf = [true, false];
|
let tf = [true, false];
|
||||||
let x = [(), ()];
|
let x = [(), ()];
|
||||||
let slice = &x[0..1];
|
let slice = &x[..1];
|
||||||
|
|
||||||
assert_repr_eq(&abc[], "[1i, 2i, 3i]".to_string());
|
assert_repr_eq(&abc[], "[1i, 2i, 3i]".to_string());
|
||||||
assert_repr_eq(&tf[], "[true, false]".to_string());
|
assert_repr_eq(&tf[], "[true, false]".to_string());
|
||||||
|
@ -17,7 +17,7 @@ fn main() {
|
|||||||
let cmp: &[int] = &[3, 4, 5];
|
let cmp: &[int] = &[3, 4, 5];
|
||||||
assert!(&x[2..] == cmp);
|
assert!(&x[2..] == cmp);
|
||||||
let cmp: &[int] = &[1, 2, 3];
|
let cmp: &[int] = &[1, 2, 3];
|
||||||
assert!(&x[0..3] == cmp);
|
assert!(&x[..3] == cmp);
|
||||||
let cmp: &[int] = &[2, 3, 4];
|
let cmp: &[int] = &[2, 3, 4];
|
||||||
assert!(&x[1..4] == cmp);
|
assert!(&x[1..4] == cmp);
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ fn main() {
|
|||||||
let cmp: &[int] = &[3, 4, 5];
|
let cmp: &[int] = &[3, 4, 5];
|
||||||
assert!(&x[2..] == cmp);
|
assert!(&x[2..] == cmp);
|
||||||
let cmp: &[int] = &[1, 2, 3];
|
let cmp: &[int] = &[1, 2, 3];
|
||||||
assert!(&x[0..3] == cmp);
|
assert!(&x[..3] == cmp);
|
||||||
let cmp: &[int] = &[2, 3, 4];
|
let cmp: &[int] = &[2, 3, 4];
|
||||||
assert!(&x[1..4] == cmp);
|
assert!(&x[1..4] == cmp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user