Skip to content

Commit 6d6c360

Browse files
committed
Audit integer type usage in core::option
1 parent 84cb71b commit 6d6c360

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/libcore/option.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@
6060
//! the optional owned box, `Option<Box<T>>`.
6161
//!
6262
//! The following example uses `Option` to create an optional box of
63-
//! `int`. Notice that in order to use the inner `int` value first the
63+
//! `i32`. Notice that in order to use the inner `i32` value first the
6464
//! `check_optional` function needs to use pattern matching to
6565
//! determine whether the box has a value (i.e. it is `Some(...)`) or
6666
//! not (`None`).
6767
//!
6868
//! ```
69-
//! let optional: Option<Box<int>> = None;
69+
//! let optional: Option<Box<i32>> = None;
7070
//! check_optional(&optional);
7171
//!
72-
//! let optional: Option<Box<int>> = Some(Box::new(9000));
72+
//! let optional: Option<Box<i32>> = Some(Box::new(9000));
7373
//! check_optional(&optional);
7474
//!
75-
//! fn check_optional(optional: &Option<Box<int>>) {
75+
//! fn check_optional(optional: &Option<Box<i32>>) {
7676
//! match *optional {
7777
//! Some(ref p) => println!("have value {}", p),
7878
//! None => println!("have no value")
@@ -108,7 +108,7 @@
108108
//! Initialize a result to `None` before a loop:
109109
//!
110110
//! ```
111-
//! enum Kingdom { Plant(uint, &'static str), Animal(uint, &'static str) }
111+
//! enum Kingdom { Plant(usize, &'static str), Animal(usize, &'static str) }
112112
//!
113113
//! // A list of data to search through.
114114
//! let all_the_big_things = [
@@ -188,10 +188,10 @@ impl<T> Option<T> {
188188
/// # Example
189189
///
190190
/// ```
191-
/// let x: Option<uint> = Some(2);
191+
/// let x: Option<usize> = Some(2);
192192
/// assert_eq!(x.is_some(), true);
193193
///
194-
/// let x: Option<uint> = None;
194+
/// let x: Option<usize> = None;
195195
/// assert_eq!(x.is_some(), false);
196196
/// ```
197197
#[inline]
@@ -208,10 +208,10 @@ impl<T> Option<T> {
208208
/// # Example
209209
///
210210
/// ```
211-
/// let x: Option<uint> = Some(2);
211+
/// let x: Option<usize> = Some(2);
212212
/// assert_eq!(x.is_none(), false);
213213
///
214-
/// let x: Option<uint> = None;
214+
/// let x: Option<usize> = None;
215215
/// assert_eq!(x.is_none(), true);
216216
/// ```
217217
#[inline]
@@ -228,7 +228,7 @@ impl<T> Option<T> {
228228
///
229229
/// # Example
230230
///
231-
/// Convert an `Option<String>` into an `Option<int>`, preserving the original.
231+
/// Convert an `Option<String>` into an `Option<usize>`, preserving the original.
232232
/// The `map` method takes the `self` argument by value, consuming the original,
233233
/// so this technique uses `as_ref` to first take an `Option` to a reference
234234
/// to the value inside the original.
@@ -237,7 +237,7 @@ impl<T> Option<T> {
237237
/// let num_as_str: Option<String> = Some("10".to_string());
238238
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
239239
/// // then consume *that* with `map`, leaving `num_as_str` on the stack.
240-
/// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
240+
/// let num_as_int: Option<usize> = num_as_str.as_ref().map(|n| n.len());
241241
/// println!("still can print num_as_str: {:?}", num_as_str);
242242
/// ```
243243
#[inline]
@@ -406,12 +406,12 @@ impl<T> Option<T> {
406406
///
407407
/// # Example
408408
///
409-
/// Convert an `Option<String>` into an `Option<uint>`, consuming the original:
409+
/// Convert an `Option<String>` into an `Option<usize>`, consuming the original:
410410
///
411411
/// ```
412412
/// let num_as_str: Option<String> = Some("10".to_string());
413413
/// // `Option::map` takes self *by value*, consuming `num_as_str`
414-
/// let num_as_int: Option<uint> = num_as_str.map(|n| n.len());
414+
/// let num_as_int: Option<usize> = num_as_str.map(|n| n.len());
415415
/// ```
416416
#[inline]
417417
#[stable(feature = "rust1", since = "1.0.0")]
@@ -518,7 +518,7 @@ impl<T> Option<T> {
518518
/// let x = Some(4);
519519
/// assert_eq!(x.iter().next(), Some(&4));
520520
///
521-
/// let x: Option<uint> = None;
521+
/// let x: Option<usize> = None;
522522
/// assert_eq!(x.iter().next(), None);
523523
/// ```
524524
#[inline]
@@ -539,7 +539,7 @@ impl<T> Option<T> {
539539
/// }
540540
/// assert_eq!(x, Some(42));
541541
///
542-
/// let mut x: Option<uint> = None;
542+
/// let mut x: Option<usize> = None;
543543
/// assert_eq!(x.iter_mut().next(), None);
544544
/// ```
545545
#[inline]
@@ -581,15 +581,15 @@ impl<T> Option<T> {
581581
/// let y: Option<&str> = None;
582582
/// assert_eq!(x.and(y), None);
583583
///
584-
/// let x: Option<uint> = None;
584+
/// let x: Option<usize> = None;
585585
/// let y = Some("foo");
586586
/// assert_eq!(x.and(y), None);
587587
///
588588
/// let x = Some(2);
589589
/// let y = Some("foo");
590590
/// assert_eq!(x.and(y), Some("foo"));
591591
///
592-
/// let x: Option<uint> = None;
592+
/// let x: Option<usize> = None;
593593
/// let y: Option<&str> = None;
594594
/// assert_eq!(x.and(y), None);
595595
/// ```
@@ -608,8 +608,8 @@ impl<T> Option<T> {
608608
/// # Example
609609
///
610610
/// ```
611-
/// fn sq(x: uint) -> Option<uint> { Some(x * x) }
612-
/// fn nope(_: uint) -> Option<uint> { None }
611+
/// fn sq(x: usize) -> Option<usize> { Some(x * x) }
612+
/// fn nope(_: usize) -> Option<usize> { None }
613613
///
614614
/// assert_eq!(Some(2).and_then(sq).and_then(sq), Some(16));
615615
/// assert_eq!(Some(2).and_then(sq).and_then(nope), None);
@@ -642,7 +642,7 @@ impl<T> Option<T> {
642642
/// let y = Some(100);
643643
/// assert_eq!(x.or(y), Some(2));
644644
///
645-
/// let x: Option<uint> = None;
645+
/// let x: Option<usize> = None;
646646
/// let y = None;
647647
/// assert_eq!(x.or(y), None);
648648
/// ```
@@ -690,7 +690,7 @@ impl<T> Option<T> {
690690
/// x.take();
691691
/// assert_eq!(x, None);
692692
///
693-
/// let mut x: Option<uint> = None;
693+
/// let mut x: Option<usize> = None;
694694
/// x.take();
695695
/// assert_eq!(x, None);
696696
/// ```
@@ -789,7 +789,7 @@ impl<A> Iterator for Item<A> {
789789
}
790790

791791
#[inline]
792-
fn size_hint(&self) -> (uint, Option<uint>) {
792+
fn size_hint(&self) -> (usize, Option<usize>) {
793793
match self.opt {
794794
Some(_) => (1, Some(1)),
795795
None => (0, Some(0)),
@@ -817,7 +817,7 @@ impl<'a, A> Iterator for Iter<'a, A> {
817817
#[inline]
818818
fn next(&mut self) -> Option<&'a A> { self.inner.next() }
819819
#[inline]
820-
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
820+
fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
821821
}
822822

823823
#[stable(feature = "rust1", since = "1.0.0")]
@@ -847,7 +847,7 @@ impl<'a, A> Iterator for IterMut<'a, A> {
847847
#[inline]
848848
fn next(&mut self) -> Option<&'a mut A> { self.inner.next() }
849849
#[inline]
850-
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
850+
fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
851851
}
852852

853853
#[stable(feature = "rust1", since = "1.0.0")]
@@ -870,7 +870,7 @@ impl<A> Iterator for IntoIter<A> {
870870
#[inline]
871871
fn next(&mut self) -> Option<A> { self.inner.next() }
872872
#[inline]
873-
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
873+
fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
874874
}
875875

876876
#[stable(feature = "rust1", since = "1.0.0")]
@@ -896,11 +896,11 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
896896
/// checking for overflow:
897897
///
898898
/// ```rust
899-
/// use std::uint;
899+
/// use std::u16;
900900
///
901901
/// let v = vec!(1, 2);
902-
/// let res: Option<Vec<uint>> = v.iter().map(|&x: &uint|
903-
/// if x == uint::MAX { None }
902+
/// let res: Option<Vec<u16>> = v.iter().map(|&x: &u16|
903+
/// if x == u16::MAX { None }
904904
/// else { Some(x + 1) }
905905
/// ).collect();
906906
/// assert!(res == Some(vec!(2, 3)));

0 commit comments

Comments
 (0)