diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-19 11:37:00 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-19 11:38:28 -0700 |
| commit | 10612ee30c31d33885f233c3e5839574fdb8be80 (patch) | |
| tree | cc25d2361e27749bdc9cb17453cae82b9b9519a4 /src/libcore | |
| parent | c97944fbf810720c2bcb0ccbe1c3149a3d9be4c0 (diff) | |
Remove superfluous by-ref in option::get, option::get_default, option::expect
Superficial change, no review.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/dlist.rs | 24 | ||||
| -rw-r--r-- | src/libcore/iter-trait/dlist.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 18 | ||||
| -rw-r--r-- | src/libcore/os.rs | 2 |
4 files changed, 23 insertions, 23 deletions
diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 3bcf486ef7e..35399878e26 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -208,7 +208,7 @@ impl<T> DList<T> { fn push_head_n(data: T) -> DListNode<T> { let mut nobe = self.new_link(move data); self.add_head(nobe); - option::get(&nobe) + option::get(nobe) } /// Add data to the tail of the list. O(1). fn push(data: T) { @@ -221,7 +221,7 @@ impl<T> DList<T> { fn push_n(data: T) -> DListNode<T> { let mut nobe = self.new_link(move data); self.add_tail(nobe); - option::get(&nobe) + option::get(nobe) } /** * Insert data into the middle of the list, left of the given node. @@ -245,7 +245,7 @@ impl<T> DList<T> { fn insert_before_n(data: T, neighbour: DListNode<T>) -> DListNode<T> { let mut nobe = self.new_link(move data); self.insert_left(nobe, neighbour); - option::get(&nobe) + option::get(nobe) } /** * Insert data into the middle of the list, right of the given node. @@ -269,7 +269,7 @@ impl<T> DList<T> { fn insert_after_n(data: T, neighbour: DListNode<T>) -> DListNode<T> { let mut nobe = self.new_link(move data); self.insert_right(neighbour, nobe); - option::get(&nobe) + option::get(nobe) } /// Remove a node from the head of the list. O(1). @@ -385,17 +385,17 @@ impl<T> DList<T> { let mut link = self.peek_n(); let mut rabbit = link; while option::is_some(&link) { - let nobe = option::get(&link); + let nobe = option::get(link); assert nobe.linked; // check cycle if option::is_some(&rabbit) { - rabbit = option::get(&rabbit).next; + rabbit = option::get(rabbit).next; } if option::is_some(&rabbit) { - rabbit = option::get(&rabbit).next; + rabbit = option::get(rabbit).next; } if option::is_some(&rabbit) { - assert !box::ptr_eq(*option::get(&rabbit), *nobe); + assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance link = nobe.next_link(); @@ -406,17 +406,17 @@ impl<T> DList<T> { link = self.peek_tail_n(); rabbit = link; while option::is_some(&link) { - let nobe = option::get(&link); + let nobe = option::get(link); assert nobe.linked; // check cycle if option::is_some(&rabbit) { - rabbit = option::get(&rabbit).prev; + rabbit = option::get(rabbit).prev; } if option::is_some(&rabbit) { - rabbit = option::get(&rabbit).prev; + rabbit = option::get(rabbit).prev; } if option::is_some(&rabbit) { - assert !box::ptr_eq(*option::get(&rabbit), *nobe); + assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance link = nobe.prev_link(); diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 2a5bb59b0c1..1b5f11569c3 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -11,7 +11,7 @@ pub type IMPL_T<A> = dlist::DList<A>; pub pure fn EACH<A>(self: &IMPL_T<A>, f: fn(v: &A) -> bool) { let mut link = self.peek_n(); while option::is_some(&link) { - let nobe = option::get(&link); + let nobe = option::get(link); assert nobe.linked; if !f(&nobe.data) { break; } // Check (weakly) that the user didn't do a remove. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 50489a82029..baabc35b428 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -42,7 +42,7 @@ pub enum Option<T> { Some(T), } -pub pure fn get<T: Copy>(opt: &Option<T>) -> T { +pub pure fn get<T: Copy>(opt: Option<T>) -> T { /*! Gets the value out of an option @@ -58,7 +58,7 @@ pub pure fn get<T: Copy>(opt: &Option<T>) -> T { case explicitly. */ - match *opt { + match opt { Some(copy x) => return x, None => fail ~"option::get none" } @@ -85,7 +85,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T { } } -pub pure fn expect<T: Copy>(opt: &Option<T>, reason: ~str) -> T { +pub pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T { /*! * Gets the value out of an option, printing a specified message on * failure @@ -94,7 +94,7 @@ pub pure fn expect<T: Copy>(opt: &Option<T>, reason: ~str) -> T { * * Fails if the value equals `none` */ - match *opt { Some(copy x) => x, None => fail reason } + match opt { Some(copy x) => x, None => fail reason } } pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> { @@ -167,10 +167,10 @@ pub pure fn is_some<T>(opt: &Option<T>) -> bool { !is_none(opt) } -pub pure fn get_default<T: Copy>(opt: &Option<T>, def: T) -> T { +pub pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T { //! Returns the contained value or a default - match *opt { Some(copy x) => x, None => def } + match opt { Some(copy x) => x, None => def } } pub pure fn map_default<T, U>(opt: &Option<T>, def: U, @@ -284,8 +284,8 @@ impl<T: Copy> Option<T> { Instead, prefer to use pattern matching and handle the `None` case explicitly. */ - pure fn get() -> T { get(&self) } - pure fn get_default(def: T) -> T { get_default(&self, def) } + pure fn get() -> T { get(self) } + pure fn get_default(def: T) -> T { get_default(self, def) } /** * Gets the value out of an option, printing a specified message on * failure @@ -294,7 +294,7 @@ impl<T: Copy> Option<T> { * * Fails if the value equals `none` */ - pure fn expect(reason: ~str) -> T { expect(&self, move reason) } + pure fn expect(reason: ~str) -> T { expect(self, move reason) } /// Applies a function zero or more times until the result is none. pure fn while_some(blk: fn(v: T) -> Option<T>) { while_some(self, blk) } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 24e4d7eff41..d201761d86b 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -473,7 +473,7 @@ pub fn tmpdir() -> Path { #[cfg(unix)] #[allow(non_implicitly_copyable_typarams)] fn lookup() -> Path { - option::get_default(&getenv_nonempty("TMPDIR"), + option::get_default(getenv_nonempty("TMPDIR"), Path("/tmp")) } |
