diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 0aa4fd68d57d..4f3f63c83fcd 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -100,7 +100,7 @@ pub pure fn build(builder: &fn(push: pure fn(v: A))) -> @[A] { #[inline(always)] pub pure fn build_sized_opt(size: Option, builder: &fn(push: pure fn(v: A))) -> @[A] { - build_sized(size.get_default(4), builder) + build_sized(size.get_or_default(4), builder) } // Appending diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index aa9660709804..db82fa14950a 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -267,7 +267,7 @@ pub pure fn build_sized_opt>( size: Option, builder: fn(push: pure fn(A))) -> B { - Buildable::build_sized(size.get_default(4), builder) + Buildable::build_sized(size.get_or_default(4), builder) } // Functions that combine iteration and building diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 5b5b3b271fff..a46736055a09 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -171,13 +171,13 @@ pub pure fn is_some(opt: &Option) -> bool { !is_none(opt) } -pub pure fn get_zero(opt: Option) -> T { +pub pure fn get_or_zero(opt: Option) -> T { //! Returns the contained value or zero (for this type) match opt { Some(copy x) => x, None => Zero::zero() } } -pub pure fn get_default(opt: Option, def: T) -> T { +pub pure fn get_or_default(opt: Option, def: T) -> T { //! Returns the contained value or a default match opt { Some(copy x) => x, None => def } @@ -331,7 +331,7 @@ impl Option { pure fn get(self) -> T { get(self) } #[inline(always)] - pure fn get_default(self, def: T) -> T { get_default(self, def) } + pure fn get_or_default(self, def: T) -> T { get_or_default(self, def) } /// Applies a function zero or more times until the result is none. #[inline(always)] @@ -342,7 +342,7 @@ impl Option { impl Option { #[inline(always)] - pure fn get_zero(self) -> T { get_zero(self) } + pure fn get_or_zero(self) -> T { get_or_zero(self) } } #[test] @@ -420,11 +420,11 @@ fn test_option_while_some() { } #[test] -fn test_get_zero() { +fn test_get_or_zero() { let some_stuff = Some(42); - assert some_stuff.get_zero() == 42; + assert some_stuff.get_or_zero() == 42; let no_stuff: Option = None; - assert no_stuff.get_zero() == 0; + assert no_stuff.get_or_zero() == 0; } // Local Variables: diff --git a/src/libcore/os.rs b/src/libcore/os.rs index c8311722ee48..2d9f95df7491 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -510,14 +510,14 @@ pub fn tmpdir() -> Path { #[cfg(unix)] #[allow(non_implicitly_copyable_typarams)] fn lookup() -> Path { - option::get_default(getenv_nonempty("TMPDIR"), + option::get_or_default(getenv_nonempty("TMPDIR"), Path("/tmp")) } #[cfg(windows)] #[allow(non_implicitly_copyable_typarams)] fn lookup() -> Path { - option::get_default( + option::get_or_default( option::or(getenv_nonempty("TMP"), option::or(getenv_nonempty("TEMP"), option::or(getenv_nonempty("USERPROFILE"), diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 17181e62005d..cdd8db6c543b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -203,7 +203,7 @@ pub pure fn build(builder: fn(push: pure fn(v: A))) -> ~[A] { #[inline(always)] pub pure fn build_sized_opt(size: Option, builder: fn(push: pure fn(v: A))) -> ~[A] { - build_sized(size.get_default(4), builder) + build_sized(size.get_or_default(4), builder) } /// Produces a mut vector from an immutable vector. diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index a9f8a485c5c7..849d56958c3e 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -113,7 +113,7 @@ fn make_target_lib_path(sysroot: &Path, sysroot.push_rel(&relative_target_lib_path(target_triple)) } -fn get_default_sysroot() -> Path { +fn get_or_default_sysroot() -> Path { match os::self_exe_path() { option::Some(ref p) => (*p).pop(), option::None => fail ~"can't determine value for sysroot" @@ -123,12 +123,12 @@ fn get_default_sysroot() -> Path { fn get_sysroot(maybe_sysroot: Option) -> Path { match maybe_sysroot { option::Some(ref sr) => (*sr), - option::None => get_default_sysroot() + option::None => get_or_default_sysroot() } } fn get_cargo_sysroot() -> Result { - result::Ok(get_default_sysroot().push_many([libdir(), ~"cargo"])) + result::Ok(get_or_default_sysroot().push_many([libdir(), ~"cargo"])) } fn get_cargo_root() -> Result { diff --git a/src/librustc/middle/trans/alt.rs b/src/librustc/middle/trans/alt.rs index 7880babbd12d..21493f8d8208 100644 --- a/src/librustc/middle/trans/alt.rs +++ b/src/librustc/middle/trans/alt.rs @@ -502,7 +502,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, match p.node { ast::pat_enum(_, subpats) => { if opt_eq(tcx, &variant_opt(tcx, p.id), opt) { - Some(option::get_default(subpats, + Some(option::get_or_default(subpats, vec::from_elem(variant_size, dummy))) } else { diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index f74c4b96e029..285e80ef25ef 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -136,7 +136,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, ccx.stats.n_monos += 1; - let depth = option::get_default(ccx.monomorphizing.find(fn_id), 0u); + let depth = option::get_or_default(ccx.monomorphizing.find(fn_id), 0u); // Random cut-off -- code that needs to instantiate the same function // recursively more than ten times can probably safely be assumed to be // causing an infinite expansion. diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 812185ec34d4..8e52fb25a946 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -69,7 +69,7 @@ fn fold_crate( { topmod: doc::ModDoc_({ item: { - name: option::get_default(attrs.name, doc.topmod.name()), + name: option::get_or_default(attrs.name, doc.topmod.name()), .. doc.topmod.item }, .. *doc.topmod diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 5bce6c8ffff7..94b3a9661847 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -154,7 +154,7 @@ fn config_from_opts( let output_dir = getopts::opt_maybe_str(matches, opt_output_dir()); let output_dir = output_dir.map(|s| Path(*s)); result::Ok({ - output_dir: output_dir.get_default(config.output_dir), + output_dir: output_dir.get_or_default(config.output_dir), .. config }) }; diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 0cd3ef0ee736..d5365d590419 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -83,7 +83,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { // drop leftmost columns that contain only values in chars fn block_trim(lines: ~[~str], chars: ~str, max: Option) -> ~[~str] { - let mut i = max.get_default(uint::max_value); + let mut i = max.get_or_default(uint::max_value); for lines.each |line| { if line.trim().is_empty() { loop;