Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f67e747

Browse files
author
Alfie John
committedJan 25, 2015
Moving away from deprecated i/u suffixes in libcore
1 parent bb7cc4e commit f67e747

File tree

19 files changed

+128
-128
lines changed

19 files changed

+128
-128
lines changed
 

‎src/libcore/atomic.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl AtomicUsize {
589589
/// ```
590590
/// use std::sync::atomic::AtomicUsize;
591591
///
592-
/// let atomic_forty_two = AtomicUsize::new(42u);
592+
/// let atomic_forty_two = AtomicUsize::new(42);
593593
/// ```
594594
#[inline]
595595
pub fn new(v: usize) -> AtomicUsize {
@@ -765,7 +765,7 @@ impl<T> AtomicPtr<T> {
765765
/// ```
766766
/// use std::sync::atomic::AtomicPtr;
767767
///
768-
/// let ptr = &mut 5i;
768+
/// let ptr = &mut 5;
769769
/// let atomic_ptr = AtomicPtr::new(ptr);
770770
/// ```
771771
#[inline]
@@ -787,7 +787,7 @@ impl<T> AtomicPtr<T> {
787787
/// ```
788788
/// use std::sync::atomic::{AtomicPtr, Ordering};
789789
///
790-
/// let ptr = &mut 5i;
790+
/// let ptr = &mut 5;
791791
/// let some_ptr = AtomicPtr::new(ptr);
792792
///
793793
/// let value = some_ptr.load(Ordering::Relaxed);
@@ -809,10 +809,10 @@ impl<T> AtomicPtr<T> {
809809
/// ```
810810
/// use std::sync::atomic::{AtomicPtr, Ordering};
811811
///
812-
/// let ptr = &mut 5i;
812+
/// let ptr = &mut 5;
813813
/// let some_ptr = AtomicPtr::new(ptr);
814814
///
815-
/// let other_ptr = &mut 10i;
815+
/// let other_ptr = &mut 10;
816816
///
817817
/// some_ptr.store(other_ptr, Ordering::Relaxed);
818818
/// ```
@@ -835,10 +835,10 @@ impl<T> AtomicPtr<T> {
835835
/// ```
836836
/// use std::sync::atomic::{AtomicPtr, Ordering};
837837
///
838-
/// let ptr = &mut 5i;
838+
/// let ptr = &mut 5;
839839
/// let some_ptr = AtomicPtr::new(ptr);
840840
///
841-
/// let other_ptr = &mut 10i;
841+
/// let other_ptr = &mut 10;
842842
///
843843
/// let value = some_ptr.swap(other_ptr, Ordering::Relaxed);
844844
/// ```
@@ -860,11 +860,11 @@ impl<T> AtomicPtr<T> {
860860
/// ```
861861
/// use std::sync::atomic::{AtomicPtr, Ordering};
862862
///
863-
/// let ptr = &mut 5i;
863+
/// let ptr = &mut 5;
864864
/// let some_ptr = AtomicPtr::new(ptr);
865865
///
866-
/// let other_ptr = &mut 10i;
867-
/// let another_ptr = &mut 10i;
866+
/// let other_ptr = &mut 10;
867+
/// let another_ptr = &mut 10;
868868
///
869869
/// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed);
870870
/// ```

‎src/libcore/cell.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@
6767
//!
6868
//! fn main() {
6969
//! let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
70-
//! shared_map.borrow_mut().insert("africa", 92388i);
71-
//! shared_map.borrow_mut().insert("kyoto", 11837i);
72-
//! shared_map.borrow_mut().insert("piccadilly", 11826i);
73-
//! shared_map.borrow_mut().insert("marbles", 38i);
70+
//! shared_map.borrow_mut().insert("africa", 92388);
71+
//! shared_map.borrow_mut().insert("kyoto", 11837);
72+
//! shared_map.borrow_mut().insert("piccadilly", 11826);
73+
//! shared_map.borrow_mut().insert("marbles", 38);
7474
//! }
7575
//! ```
7676
//!

‎src/libcore/char.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
102102
if num < 10 {
103103
Some(transmute(('0' as uint + num) as u32))
104104
} else {
105-
Some(transmute(('a' as uint + num - 10u) as u32))
105+
Some(transmute(('a' as uint + num - 10) as u32))
106106
}
107107
}
108108
} else {
@@ -208,8 +208,8 @@ impl CharExt for char {
208208
}
209209
let val = match self {
210210
'0' ... '9' => self as uint - ('0' as uint),
211-
'a' ... 'z' => self as uint + 10u - ('a' as uint),
212-
'A' ... 'Z' => self as uint + 10u - ('A' as uint),
211+
'a' ... 'z' => self as uint + 10 - ('a' as uint),
212+
'A' ... 'Z' => self as uint + 10 - ('A' as uint),
213213
_ => return None,
214214
};
215215
if val < radix { Some(val) }
@@ -241,10 +241,10 @@ impl CharExt for char {
241241
fn len_utf8(self) -> uint {
242242
let code = self as u32;
243243
match () {
244-
_ if code < MAX_ONE_B => 1u,
245-
_ if code < MAX_TWO_B => 2u,
246-
_ if code < MAX_THREE_B => 3u,
247-
_ => 4u,
244+
_ if code < MAX_ONE_B => 1,
245+
_ if code < MAX_TWO_B => 2,
246+
_ if code < MAX_THREE_B => 3,
247+
_ => 4,
248248
}
249249
}
250250

@@ -359,7 +359,7 @@ impl Iterator for EscapeUnicode {
359359
Some('u')
360360
}
361361
EscapeUnicodeState::LeftBrace => {
362-
let mut n = 0u;
362+
let mut n = 0;
363363
while (self.c as u32) >> (4 * (n + 1)) != 0 {
364364
n += 1;
365365
}

‎src/libcore/cmp.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ pub trait Eq: PartialEq<Self> {
110110
pub enum Ordering {
111111
/// An ordering where a compared value is less [than another].
112112
#[stable]
113-
Less = -1i,
113+
Less = -1,
114114
/// An ordering where a compared value is equal [to another].
115115
#[stable]
116-
Equal = 0i,
116+
Equal = 0,
117117
/// An ordering where a compared value is greater [than another].
118118
#[stable]
119-
Greater = 1i,
119+
Greater = 1,
120120
}
121121

122122
impl Ordering {
@@ -132,12 +132,12 @@ impl Ordering {
132132
/// assert_eq!(Equal.reverse(), Equal);
133133
/// assert_eq!(Greater.reverse(), Less);
134134
///
135-
/// let mut data: &mut [_] = &mut [2u, 10, 5, 8];
135+
/// let mut data: &mut [_] = &mut [2, 10, 5, 8];
136136
///
137137
/// // sort the array from largest to smallest.
138138
/// data.sort_by(|a, b| a.cmp(b).reverse());
139139
///
140-
/// let b: &mut [_] = &mut [10u, 8, 5, 2];
140+
/// let b: &mut [_] = &mut [10, 8, 5, 2];
141141
/// assert!(data == b);
142142
/// ```
143143
#[inline]
@@ -174,9 +174,9 @@ pub trait Ord: Eq + PartialOrd<Self> {
174174
/// ```
175175
/// use std::cmp::Ordering::{Less, Equal, Greater};
176176
///
177-
/// assert_eq!( 5u.cmp(&10), Less); // because 5 < 10
178-
/// assert_eq!(10u.cmp(&5), Greater); // because 10 > 5
179-
/// assert_eq!( 5u.cmp(&5), Equal); // because 5 == 5
177+
/// assert_eq!( 5.cmp(&10), Less); // because 5 < 10
178+
/// assert_eq!(10.cmp(&5), Greater); // because 10 > 5
179+
/// assert_eq!( 5.cmp(&5), Equal); // because 5 == 5
180180
/// ```
181181
#[stable]
182182
fn cmp(&self, other: &Self) -> Ordering;

‎src/libcore/default.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,17 @@ default_impl! { (), () }
150150
default_impl! { bool, false }
151151
default_impl! { char, '\x00' }
152152

153-
default_impl! { uint, 0u }
154-
default_impl! { u8, 0u8 }
155-
default_impl! { u16, 0u16 }
156-
default_impl! { u32, 0u32 }
157-
default_impl! { u64, 0u64 }
153+
default_impl! { uint, 0 }
154+
default_impl! { u8, 0 }
155+
default_impl! { u16, 0 }
156+
default_impl! { u32, 0 }
157+
default_impl! { u64, 0 }
158158

159-
default_impl! { int, 0i }
160-
default_impl! { i8, 0i8 }
161-
default_impl! { i16, 0i16 }
162-
default_impl! { i32, 0i32 }
163-
default_impl! { i64, 0i64 }
159+
default_impl! { int, 0 }
160+
default_impl! { i8, 0 }
161+
default_impl! { i16, 0 }
162+
default_impl! { i32, 0 }
163+
default_impl! { i64, 0 }
164164

165165
default_impl! { f32, 0.0f32 }
166166
default_impl! { f64, 0.0f64 }

‎src/libcore/fmt/float.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum SignFormat {
5353
SignNeg
5454
}
5555

56-
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
56+
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11;
5757

5858
/// Converts a number to its string representation as a byte vector.
5959
/// This is meant to be a common base implementation for all numeric string
@@ -191,7 +191,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
191191
if deccum != _0 || (limit_digits && exact && digit_count > 0) {
192192
buf[end] = b'.';
193193
end += 1;
194-
let mut dig = 0u;
194+
let mut dig = 0;
195195

196196
// calculate new digits while
197197
// - there is no limit and there are digits left
@@ -218,7 +218,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
218218

219219
// Decrease the deccumulator one fractional digit at a time
220220
deccum = deccum.fract();
221-
dig += 1u;
221+
dig += 1;
222222
}
223223

224224
// If digits are limited, and that limit has been reached,

‎src/libcore/fmt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ impl<'a> Formatter<'a> {
560560
};
561561

562562
let (pre_pad, post_pad) = match align {
563-
rt::AlignLeft => (0u, padding),
564-
rt::AlignRight | rt::AlignUnknown => (padding, 0u),
563+
rt::AlignLeft => (0, padding),
564+
rt::AlignRight | rt::AlignUnknown => (padding, 0),
565565
rt::AlignCenter => (padding / 2, (padding + 1) / 2),
566566
};
567567

@@ -846,7 +846,7 @@ macro_rules! tuple {
846846
fn fmt(&self, f: &mut Formatter) -> Result {
847847
try!(write!(f, "("));
848848
let ($(ref $name,)*) = *self;
849-
let mut n = 0i;
849+
let mut n = 0;
850850
$(
851851
if n > 0 {
852852
try!(write!(f, ", "));

‎src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub struct RadixFmt<T, R>(T, R);
145145
///
146146
/// ```
147147
/// use std::fmt::radix;
148-
/// assert_eq!(format!("{}", radix(55i, 36)), "1j".to_string());
148+
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
149149
/// ```
150150
#[unstable = "may be renamed or move to a different module"]
151151
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {

‎src/libcore/hash/sip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Writer for SipHasher {
122122
let length = msg.len();
123123
self.length += length;
124124

125-
let mut needed = 0u;
125+
let mut needed = 0;
126126

127127
if self.ntail != 0 {
128128
needed = 8 - self.ntail;

‎src/libcore/iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! translated to the `loop` below.
3434
//!
3535
//! ```
36-
//! let values = vec![1i, 2, 3];
36+
//! let values = vec![1, 2, 3];
3737
//!
3838
//! // "Syntactical sugar" taking advantage of an iterator
3939
//! for &x in values.iter() {
@@ -615,7 +615,7 @@ pub trait IteratorExt: Iterator + Sized {
615615
/// # Examples
616616
///
617617
/// ```
618-
/// let a = [1i, 2, 3, 4, 5];
618+
/// let a = [1, 2, 3, 4, 5];
619619
/// assert!(a.iter().all(|x| *x > 0));
620620
/// assert!(!a.iter().all(|x| *x > 2));
621621
/// ```
@@ -1141,7 +1141,7 @@ pub trait AdditiveIterator<A> {
11411141
/// ```
11421142
/// use std::iter::AdditiveIterator;
11431143
///
1144-
/// let a = [1i, 2, 3, 4, 5];
1144+
/// let a = [1i32, 2, 3, 4, 5];
11451145
/// let mut it = a.iter().map(|&x| x);
11461146
/// assert!(it.sum() == 15);
11471147
/// ```
@@ -1183,7 +1183,7 @@ pub trait MultiplicativeIterator<A> {
11831183
/// use std::iter::{count, MultiplicativeIterator};
11841184
///
11851185
/// fn factorial(n: usize) -> usize {
1186-
/// count(1u, 1).take_while(|&i| i <= n).product()
1186+
/// count(1, 1).take_while(|&i| i <= n).product()
11871187
/// }
11881188
/// assert!(factorial(0) == 1);
11891189
/// assert!(factorial(1) == 1);
@@ -2526,7 +2526,7 @@ pub struct Range<A> {
25262526
/// ```
25272527
/// let array = [0, 1, 2, 3, 4];
25282528
///
2529-
/// for i in range(0, 5u) {
2529+
/// for i in range(0, 5) {
25302530
/// println!("{}", i);
25312531
/// assert_eq!(i, array[i]);
25322532
/// }

‎src/libcore/macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ macro_rules! panic {
4848
/// let x = true;
4949
/// assert!(x, "x wasn't true!");
5050
///
51-
/// let a = 3i; let b = 27i;
51+
/// let a = 3; let b = 27;
5252
/// assert!(a + b == 30, "a = {}, b = {}", a, b);
5353
/// ```
5454
#[macro_export]
@@ -74,8 +74,8 @@ macro_rules! assert {
7474
/// # Example
7575
///
7676
/// ```
77-
/// let a = 3i;
78-
/// let b = 1i + 2i;
77+
/// let a = 3;
78+
/// let b = 1 + 2;
7979
/// assert_eq!(a, b);
8080
/// ```
8181
#[macro_export]
@@ -141,8 +141,8 @@ macro_rules! debug_assert {
141141
/// # Example
142142
///
143143
/// ```
144-
/// let a = 3i;
145-
/// let b = 1i + 2i;
144+
/// let a = 3;
145+
/// let b = 1 + 2;
146146
/// debug_assert_eq!(a, b);
147147
/// ```
148148
#[macro_export]

‎src/libcore/mem.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ pub unsafe fn uninitialized<T>() -> T {
187187
/// ```
188188
/// use std::mem;
189189
///
190-
/// let x = &mut 5i;
191-
/// let y = &mut 42i;
190+
/// let x = &mut 5;
191+
/// let y = &mut 42;
192192
///
193193
/// mem::swap(x, y);
194194
///
195-
/// assert_eq!(42i, *x);
196-
/// assert_eq!(5i, *y);
195+
/// assert_eq!(42, *x);
196+
/// assert_eq!(5, *y);
197197
/// ```
198198
#[inline]
199199
#[stable]
@@ -277,7 +277,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
277277
/// ```
278278
/// use std::cell::RefCell;
279279
///
280-
/// let x = RefCell::new(1i);
280+
/// let x = RefCell::new(1);
281281
///
282282
/// let mut mutable_borrow = x.borrow_mut();
283283
/// *mutable_borrow = 1;
@@ -306,9 +306,9 @@ pub fn drop<T>(_x: T) { }
306306
/// ```
307307
/// use std::mem;
308308
///
309-
/// let one = unsafe { mem::transmute_copy(&1i) };
309+
/// let one = unsafe { mem::transmute_copy(&1) };
310310
///
311-
/// assert_eq!(1u, one);
311+
/// assert_eq!(1, one);
312312
/// ```
313313
#[inline]
314314
#[stable]

‎src/libcore/num/f32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ use num::FpCategory as Fp;
2323
use option::Option;
2424

2525
#[unstable = "pending integer conventions"]
26-
pub const RADIX: uint = 2u;
26+
pub const RADIX: uint = 2;
2727

2828
#[unstable = "pending integer conventions"]
29-
pub const MANTISSA_DIGITS: uint = 24u;
29+
pub const MANTISSA_DIGITS: uint = 24;
3030
#[unstable = "pending integer conventions"]
31-
pub const DIGITS: uint = 6u;
31+
pub const DIGITS: uint = 6;
3232

3333
#[stable]
3434
pub const EPSILON: f32 = 1.19209290e-07_f32;

‎src/libcore/num/f64.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ use option::Option;
2727
// members of `Bounded` and `Float`.
2828

2929
#[unstable = "pending integer conventions"]
30-
pub const RADIX: uint = 2u;
30+
pub const RADIX: uint = 2;
3131

32-
pub const MANTISSA_DIGITS: uint = 53u;
32+
pub const MANTISSA_DIGITS: uint = 53;
3333
#[unstable = "pending integer conventions"]
34-
pub const DIGITS: uint = 15u;
34+
pub const DIGITS: uint = 15;
3535

3636
#[stable]
3737
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

‎src/libcore/num/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub trait Int
356356
/// ```rust
357357
/// use std::num::Int;
358358
///
359-
/// assert_eq!(2i.pow(4), 16);
359+
/// assert_eq!(2.pow(4), 16);
360360
/// ```
361361
#[unstable = "pending integer conventions"]
362362
#[inline]
@@ -1185,7 +1185,7 @@ impl_from_primitive! { f64, to_f64 }
11851185
/// ```
11861186
/// use std::num;
11871187
///
1188-
/// let twenty: f32 = num::cast(0x14i).unwrap();
1188+
/// let twenty: f32 = num::cast(0x14).unwrap();
11891189
/// assert_eq!(twenty, 20f32);
11901190
/// ```
11911191
///
@@ -1571,8 +1571,8 @@ macro_rules! from_str_radix_float_impl {
15711571
let exp = match exp_info {
15721572
Some((c, offset)) => {
15731573
let base = match c {
1574-
'E' | 'e' if radix == 10 => 10u as $T,
1575-
'P' | 'p' if radix == 16 => 2u as $T,
1574+
'E' | 'e' if radix == 10 => 10.0,
1575+
'P' | 'p' if radix == 16 => 2.0,
15761576
_ => return None,
15771577
};
15781578

‎src/libcore/option.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ impl<T> Option<T> {
254254
/// # Example
255255
///
256256
/// ```
257-
/// let mut x = Some(2u);
257+
/// let mut x = Some(2);
258258
/// match x.as_mut() {
259259
/// Some(v) => *v = 42,
260260
/// None => {},
261261
/// }
262-
/// assert_eq!(x, Some(42u));
262+
/// assert_eq!(x, Some(42));
263263
/// ```
264264
#[inline]
265265
#[stable]
@@ -384,9 +384,9 @@ impl<T> Option<T> {
384384
/// # Example
385385
///
386386
/// ```
387-
/// let k = 10u;
388-
/// assert_eq!(Some(4u).unwrap_or_else(|| 2 * k), 4u);
389-
/// assert_eq!(None.unwrap_or_else(|| 2 * k), 20u);
387+
/// let k = 10i32;
388+
/// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);
389+
/// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);
390390
/// ```
391391
#[inline]
392392
#[stable]
@@ -427,10 +427,10 @@ impl<T> Option<T> {
427427
///
428428
/// ```
429429
/// let x = Some("foo");
430-
/// assert_eq!(x.map_or(42u, |v| v.len()), 3u);
430+
/// assert_eq!(x.map_or(42, |v| v.len()), 3);
431431
///
432432
/// let x: Option<&str> = None;
433-
/// assert_eq!(x.map_or(42u, |v| v.len()), 42u);
433+
/// assert_eq!(x.map_or(42, |v| v.len()), 42);
434434
/// ```
435435
#[inline]
436436
#[stable]
@@ -446,13 +446,13 @@ impl<T> Option<T> {
446446
/// # Example
447447
///
448448
/// ```
449-
/// let k = 21u;
449+
/// let k = 21;
450450
///
451451
/// let x = Some("foo");
452-
/// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3u);
452+
/// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 3);
453453
///
454454
/// let x: Option<&str> = None;
455-
/// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42u);
455+
/// assert_eq!(x.map_or_else(|| 2 * k, |v| v.len()), 42);
456456
/// ```
457457
#[inline]
458458
#[stable]
@@ -470,10 +470,10 @@ impl<T> Option<T> {
470470
///
471471
/// ```
472472
/// let x = Some("foo");
473-
/// assert_eq!(x.ok_or(0i), Ok("foo"));
473+
/// assert_eq!(x.ok_or(0), Ok("foo"));
474474
///
475475
/// let x: Option<&str> = None;
476-
/// assert_eq!(x.ok_or(0i), Err(0i));
476+
/// assert_eq!(x.ok_or(0), Err(0));
477477
/// ```
478478
#[inline]
479479
#[unstable]
@@ -491,10 +491,10 @@ impl<T> Option<T> {
491491
///
492492
/// ```
493493
/// let x = Some("foo");
494-
/// assert_eq!(x.ok_or_else(|| 0i), Ok("foo"));
494+
/// assert_eq!(x.ok_or_else(|| 0), Ok("foo"));
495495
///
496496
/// let x: Option<&str> = None;
497-
/// assert_eq!(x.ok_or_else(|| 0i), Err(0i));
497+
/// assert_eq!(x.ok_or_else(|| 0), Err(0));
498498
/// ```
499499
#[inline]
500500
#[unstable]
@@ -514,7 +514,7 @@ impl<T> Option<T> {
514514
/// # Example
515515
///
516516
/// ```
517-
/// let x = Some(4u);
517+
/// let x = Some(4);
518518
/// assert_eq!(x.iter().next(), Some(&4));
519519
///
520520
/// let x: Option<uint> = None;
@@ -531,9 +531,9 @@ impl<T> Option<T> {
531531
/// # Example
532532
///
533533
/// ```
534-
/// let mut x = Some(4u);
534+
/// let mut x = Some(4);
535535
/// match x.iter_mut().next() {
536-
/// Some(&mut ref mut v) => *v = 42u,
536+
/// Some(&mut ref mut v) => *v = 42,
537537
/// None => {},
538538
/// }
539539
/// assert_eq!(x, Some(42));
@@ -575,15 +575,15 @@ impl<T> Option<T> {
575575
/// # Example
576576
///
577577
/// ```
578-
/// let x = Some(2u);
578+
/// let x = Some(2);
579579
/// let y: Option<&str> = None;
580580
/// assert_eq!(x.and(y), None);
581581
///
582582
/// let x: Option<uint> = None;
583583
/// let y = Some("foo");
584584
/// assert_eq!(x.and(y), None);
585585
///
586-
/// let x = Some(2u);
586+
/// let x = Some(2);
587587
/// let y = Some("foo");
588588
/// assert_eq!(x.and(y), Some("foo"));
589589
///
@@ -628,17 +628,17 @@ impl<T> Option<T> {
628628
/// # Example
629629
///
630630
/// ```
631-
/// let x = Some(2u);
631+
/// let x = Some(2);
632632
/// let y = None;
633-
/// assert_eq!(x.or(y), Some(2u));
633+
/// assert_eq!(x.or(y), Some(2));
634634
///
635635
/// let x = None;
636-
/// let y = Some(100u);
637-
/// assert_eq!(x.or(y), Some(100u));
636+
/// let y = Some(100);
637+
/// assert_eq!(x.or(y), Some(100));
638638
///
639-
/// let x = Some(2u);
640-
/// let y = Some(100u);
641-
/// assert_eq!(x.or(y), Some(2u));
639+
/// let x = Some(2);
640+
/// let y = Some(100);
641+
/// assert_eq!(x.or(y), Some(2));
642642
///
643643
/// let x: Option<uint> = None;
644644
/// let y = None;
@@ -684,7 +684,7 @@ impl<T> Option<T> {
684684
/// # Example
685685
///
686686
/// ```
687-
/// let mut x = Some(2u);
687+
/// let mut x = Some(2);
688688
/// x.take();
689689
/// assert_eq!(x, None);
690690
///
@@ -728,8 +728,8 @@ impl<T: Default> Option<T> {
728728
/// let good_year = good_year_from_input.parse().unwrap_or_default();
729729
/// let bad_year = bad_year_from_input.parse().unwrap_or_default();
730730
///
731-
/// assert_eq!(1909i, good_year);
732-
/// assert_eq!(0i, bad_year);
731+
/// assert_eq!(1909, good_year);
732+
/// assert_eq!(0, bad_year);
733733
/// ```
734734
#[inline]
735735
#[stable]
@@ -894,12 +894,12 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
894894
/// ```rust
895895
/// use std::uint;
896896
///
897-
/// let v = vec!(1u, 2u);
897+
/// let v = vec!(1, 2);
898898
/// let res: Option<Vec<uint>> = v.iter().map(|&x: &uint|
899899
/// if x == uint::MAX { None }
900900
/// else { Some(x + 1) }
901901
/// ).collect();
902-
/// assert!(res == Some(vec!(2u, 3u)));
902+
/// assert!(res == Some(vec!(2, 3)));
903903
/// ```
904904
#[inline]
905905
#[stable]

‎src/libcore/result.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ impl<T, E> Result<T, E> {
482482
/// ```
483483
/// fn stringify(x: uint) -> String { format!("error code: {}", x) }
484484
///
485-
/// let x: Result<uint, uint> = Ok(2u);
486-
/// assert_eq!(x.map_err(stringify), Ok(2u));
485+
/// let x: Result<uint, uint> = Ok(2);
486+
/// assert_eq!(x.map_err(stringify), Ok(2));
487487
///
488488
/// let x: Result<uint, uint> = Err(13);
489489
/// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string()));
@@ -546,7 +546,7 @@ impl<T, E> Result<T, E> {
546546
/// ```
547547
/// let x: Result<uint, &str> = Ok(5);
548548
/// let v: Vec<uint> = x.into_iter().collect();
549-
/// assert_eq!(v, vec![5u]);
549+
/// assert_eq!(v, vec![5]);
550550
///
551551
/// let x: Result<uint, &str> = Err("nothing!");
552552
/// let v: Vec<uint> = x.into_iter().collect();
@@ -676,9 +676,9 @@ impl<T, E> Result<T, E> {
676676
/// # Example
677677
///
678678
/// ```
679-
/// let optb = 2u;
680-
/// let x: Result<uint, &str> = Ok(9u);
681-
/// assert_eq!(x.unwrap_or(optb), 9u);
679+
/// let optb = 2;
680+
/// let x: Result<uint, &str> = Ok(9);
681+
/// assert_eq!(x.unwrap_or(optb), 9);
682682
///
683683
/// let x: Result<uint, &str> = Err("error");
684684
/// assert_eq!(x.unwrap_or(optb), optb);
@@ -700,8 +700,8 @@ impl<T, E> Result<T, E> {
700700
/// ```
701701
/// fn count(x: &str) -> uint { x.len() }
702702
///
703-
/// assert_eq!(Ok(2u).unwrap_or_else(count), 2u);
704-
/// assert_eq!(Err("foo").unwrap_or_else(count), 3u);
703+
/// assert_eq!(Ok(2).unwrap_or_else(count), 2);
704+
/// assert_eq!(Err("foo").unwrap_or_else(count), 3);
705705
/// ```
706706
#[inline]
707707
#[stable]
@@ -725,8 +725,8 @@ impl<T, E: Display> Result<T, E> {
725725
/// # Example
726726
///
727727
/// ```
728-
/// let x: Result<uint, &str> = Ok(2u);
729-
/// assert_eq!(x.unwrap(), 2u);
728+
/// let x: Result<uint, &str> = Ok(2);
729+
/// assert_eq!(x.unwrap(), 2);
730730
/// ```
731731
///
732732
/// ```{.should_fail}
@@ -756,7 +756,7 @@ impl<T: Display, E> Result<T, E> {
756756
/// # Example
757757
///
758758
/// ```{.should_fail}
759-
/// let x: Result<uint, &str> = Ok(2u);
759+
/// let x: Result<uint, &str> = Ok(2);
760760
/// x.unwrap_err(); // panics with `2`
761761
/// ```
762762
///
@@ -897,12 +897,12 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
897897
/// ```rust
898898
/// use std::uint;
899899
///
900-
/// let v = vec!(1u, 2u);
900+
/// let v = vec!(1, 2);
901901
/// let res: Result<Vec<uint>, &'static str> = v.iter().map(|&x: &uint|
902902
/// if x == uint::MAX { Err("Overflow!") }
903903
/// else { Ok(x + 1) }
904904
/// ).collect();
905-
/// assert!(res == Ok(vec!(2u, 3u)));
905+
/// assert!(res == Ok(vec!(2, 3)));
906906
/// ```
907907
#[inline]
908908
fn from_iter<I: Iterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> {

‎src/libcore/slice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ macro_rules! iterator {
653653
self.ptr = transmute(self.ptr as uint + 1);
654654

655655
// Use a non-null pointer value
656-
Some(transmute(1u))
656+
Some(&mut *(1 as *mut _))
657657
} else {
658658
let old = self.ptr;
659659
self.ptr = self.ptr.offset(1);
@@ -687,7 +687,7 @@ macro_rules! iterator {
687687
self.end = transmute(self.end as uint - 1);
688688

689689
// Use a non-null pointer value
690-
Some(transmute(1u))
690+
Some(&mut *(1 as *mut _))
691691
} else {
692692
self.end = self.end.offset(-1);
693693

@@ -795,7 +795,7 @@ impl<'a, T> RandomAccessIterator for Iter<'a, T> {
795795
if index < self.indexable() {
796796
if mem::size_of::<T>() == 0 {
797797
// Use a non-null pointer value
798-
Some(transmute(1u))
798+
Some(&mut *(1 as *mut _))
799799
} else {
800800
Some(transmute(self.ptr.offset(index as int)))
801801
}
@@ -1175,7 +1175,7 @@ impl<'a, T> Iterator for Windows<'a, T> {
11751175
(0, Some(0))
11761176
} else {
11771177
let x = self.v.len() - self.size;
1178-
(x.saturating_add(1), x.checked_add(1u))
1178+
(x.saturating_add(1), x.checked_add(1))
11791179
}
11801180
}
11811181
}

‎src/libcore/str/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ pub unsafe fn from_utf8_unchecked<'a>(v: &'a [u8]) -> &'a str {
198198
#[deprecated = "use std::ffi::c_str_to_bytes + str::from_utf8"]
199199
pub unsafe fn from_c_str(s: *const i8) -> &'static str {
200200
let s = s as *const u8;
201-
let mut len = 0u;
201+
let mut len = 0;
202202
while *s.offset(len as int) != 0 {
203-
len += 1u;
203+
len += 1;
204204
}
205205
let v: &'static [u8] = ::mem::transmute(Slice { data: s, len: len });
206206
from_utf8(v).ok().expect("from_c_str passed invalid utf-8 data")
@@ -1510,7 +1510,7 @@ impl StrExt for str {
15101510
None => "",
15111511
Some(last) => {
15121512
let next = self.char_range_at(last).next;
1513-
unsafe { self.slice_unchecked(0u, next) }
1513+
unsafe { self.slice_unchecked(0, next) }
15141514
}
15151515
}
15161516
}
@@ -1543,7 +1543,7 @@ impl StrExt for str {
15431543
fn multibyte_char_range_at_reverse(s: &str, mut i: uint) -> CharRange {
15441544
// while there is a previous byte == 10......
15451545
while i > 0 && s.as_bytes()[i] & !CONT_MASK == TAG_CONT_U8 {
1546-
i -= 1u;
1546+
i -= 1;
15471547
}
15481548

15491549
let mut val = s.as_bytes()[i] as u32;
@@ -1613,7 +1613,7 @@ impl StrExt for str {
16131613
if self.is_empty() {
16141614
None
16151615
} else {
1616-
let CharRange {ch, next} = self.char_range_at(0u);
1616+
let CharRange {ch, next} = self.char_range_at(0);
16171617
let next_s = unsafe { self.slice_unchecked(next, self.len()) };
16181618
Some((ch, next_s))
16191619
}

0 commit comments

Comments
 (0)
Please sign in to comment.