Skip to content

Commit 89acd1f

Browse files
committed
Rename option::get_default => get_or_default, get_zero => get_or_zero
1 parent 4d8cc3f commit 89acd1f

File tree

11 files changed

+20
-20
lines changed

11 files changed

+20
-20
lines changed

src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] {
100100
#[inline(always)]
101101
pub pure fn build_sized_opt<A>(size: Option<uint>,
102102
builder: &fn(push: pure fn(v: A))) -> @[A] {
103-
build_sized(size.get_default(4), builder)
103+
build_sized(size.get_or_default(4), builder)
104104
}
105105

106106
// Appending

src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub pure fn build_sized_opt<A,B: Buildable<A>>(
267267
size: Option<uint>,
268268
builder: fn(push: pure fn(A))) -> B {
269269

270-
Buildable::build_sized(size.get_default(4), builder)
270+
Buildable::build_sized(size.get_or_default(4), builder)
271271
}
272272

273273
// Functions that combine iteration and building

src/libcore/option.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ pub pure fn is_some<T>(opt: &Option<T>) -> bool {
171171
!is_none(opt)
172172
}
173173

174-
pub pure fn get_zero<T: Copy Zero>(opt: Option<T>) -> T {
174+
pub pure fn get_or_zero<T: Copy Zero>(opt: Option<T>) -> T {
175175
//! Returns the contained value or zero (for this type)
176176
177177
match opt { Some(copy x) => x, None => Zero::zero() }
178178
}
179179

180-
pub pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T {
180+
pub pure fn get_or_default<T: Copy>(opt: Option<T>, def: T) -> T {
181181
//! Returns the contained value or a default
182182
183183
match opt { Some(copy x) => x, None => def }
@@ -331,7 +331,7 @@ impl<T: Copy> Option<T> {
331331
pure fn get(self) -> T { get(self) }
332332

333333
#[inline(always)]
334-
pure fn get_default(self, def: T) -> T { get_default(self, def) }
334+
pure fn get_or_default(self, def: T) -> T { get_or_default(self, def) }
335335

336336
/// Applies a function zero or more times until the result is none.
337337
#[inline(always)]
@@ -342,7 +342,7 @@ impl<T: Copy> Option<T> {
342342

343343
impl<T: Copy Zero> Option<T> {
344344
#[inline(always)]
345-
pure fn get_zero(self) -> T { get_zero(self) }
345+
pure fn get_or_zero(self) -> T { get_or_zero(self) }
346346
}
347347

348348
#[test]
@@ -420,11 +420,11 @@ fn test_option_while_some() {
420420
}
421421

422422
#[test]
423-
fn test_get_zero() {
423+
fn test_get_or_zero() {
424424
let some_stuff = Some(42);
425-
assert some_stuff.get_zero() == 42;
425+
assert some_stuff.get_or_zero() == 42;
426426
let no_stuff: Option<int> = None;
427-
assert no_stuff.get_zero() == 0;
427+
assert no_stuff.get_or_zero() == 0;
428428
}
429429

430430
// Local Variables:

src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,14 @@ pub fn tmpdir() -> Path {
510510
#[cfg(unix)]
511511
#[allow(non_implicitly_copyable_typarams)]
512512
fn lookup() -> Path {
513-
option::get_default(getenv_nonempty("TMPDIR"),
513+
option::get_or_default(getenv_nonempty("TMPDIR"),
514514
Path("/tmp"))
515515
}
516516

517517
#[cfg(windows)]
518518
#[allow(non_implicitly_copyable_typarams)]
519519
fn lookup() -> Path {
520-
option::get_default(
520+
option::get_or_default(
521521
option::or(getenv_nonempty("TMP"),
522522
option::or(getenv_nonempty("TEMP"),
523523
option::or(getenv_nonempty("USERPROFILE"),

src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub pure fn build<A>(builder: fn(push: pure fn(v: A))) -> ~[A] {
203203
#[inline(always)]
204204
pub pure fn build_sized_opt<A>(size: Option<uint>,
205205
builder: fn(push: pure fn(v: A))) -> ~[A] {
206-
build_sized(size.get_default(4), builder)
206+
build_sized(size.get_or_default(4), builder)
207207
}
208208

209209
/// Produces a mut vector from an immutable vector.

src/librustc/metadata/filesearch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn make_target_lib_path(sysroot: &Path,
113113
sysroot.push_rel(&relative_target_lib_path(target_triple))
114114
}
115115

116-
fn get_default_sysroot() -> Path {
116+
fn get_or_default_sysroot() -> Path {
117117
match os::self_exe_path() {
118118
option::Some(ref p) => (*p).pop(),
119119
option::None => fail ~"can't determine value for sysroot"
@@ -123,12 +123,12 @@ fn get_default_sysroot() -> Path {
123123
fn get_sysroot(maybe_sysroot: Option<Path>) -> Path {
124124
match maybe_sysroot {
125125
option::Some(ref sr) => (*sr),
126-
option::None => get_default_sysroot()
126+
option::None => get_or_default_sysroot()
127127
}
128128
}
129129

130130
fn get_cargo_sysroot() -> Result<Path, ~str> {
131-
result::Ok(get_default_sysroot().push_many([libdir(), ~"cargo"]))
131+
result::Ok(get_or_default_sysroot().push_many([libdir(), ~"cargo"]))
132132
}
133133

134134
fn get_cargo_root() -> Result<Path, ~str> {

src/librustc/middle/trans/alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
502502
match p.node {
503503
ast::pat_enum(_, subpats) => {
504504
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
505-
Some(option::get_default(subpats,
505+
Some(option::get_or_default(subpats,
506506
vec::from_elem(variant_size,
507507
dummy)))
508508
} else {

src/librustc/middle/trans/monomorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
136136

137137
ccx.stats.n_monos += 1;
138138

139-
let depth = option::get_default(ccx.monomorphizing.find(fn_id), 0u);
139+
let depth = option::get_or_default(ccx.monomorphizing.find(fn_id), 0u);
140140
// Random cut-off -- code that needs to instantiate the same function
141141
// recursively more than ten times can probably safely be assumed to be
142142
// causing an infinite expansion.

src/librustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn fold_crate(
6969
{
7070
topmod: doc::ModDoc_({
7171
item: {
72-
name: option::get_default(attrs.name, doc.topmod.name()),
72+
name: option::get_or_default(attrs.name, doc.topmod.name()),
7373
.. doc.topmod.item
7474
},
7575
.. *doc.topmod

src/librustdoc/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn config_from_opts(
154154
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
155155
let output_dir = output_dir.map(|s| Path(*s));
156156
result::Ok({
157-
output_dir: output_dir.get_default(config.output_dir),
157+
output_dir: output_dir.get_or_default(config.output_dir),
158158
.. config
159159
})
160160
};

src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str {
8383
// drop leftmost columns that contain only values in chars
8484
fn block_trim(lines: ~[~str], chars: ~str, max: Option<uint>) -> ~[~str] {
8585
86-
let mut i = max.get_default(uint::max_value);
86+
let mut i = max.get_or_default(uint::max_value);
8787
for lines.each |line| {
8888
if line.trim().is_empty() {
8989
loop;

0 commit comments

Comments
 (0)