std: rename Option::unwrap_or_default() to unwrap_or()

This commit is contained in:
Erick Tryzelaar 2013-09-09 19:57:08 -07:00
parent 761ae00357
commit 45c62c08f9
12 changed files with 18 additions and 19 deletions

View File

@ -309,7 +309,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
let filename = path.filename();
let p = path.pop();
let dir = p.filename();
fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default(""))
fmt!("%s/%s", dir.unwrap_or(""), filename.unwrap_or(""))
}
test::DynTestName(fmt!("[%s] %s",

View File

@ -312,7 +312,7 @@ impl Pattern {
let require_literal = |c| {
(options.require_literal_separator && is_sep(c)) ||
(options.require_literal_leading_dot && c == '.'
&& is_sep(prev_char.unwrap_or_default('/')))
&& is_sep(prev_char.unwrap_or('/')))
};
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {

View File

@ -681,9 +681,9 @@ pub fn build_session_options(binary: @str,
link::output_type_bitcode
} else { link::output_type_exe };
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
let target = getopts::opt_maybe_str(matches, "target").unwrap_or_default(host_triple());
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or_default(~"generic");
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or_default(~"");
let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple());
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic");
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~"");
let save_temps = getopts::opt_present(matches, "save-temps");
let opt_level = {
if (debugging_opts & session::no_opt) != 0 {

View File

@ -221,8 +221,7 @@ impl PrivacyVisitor {
// If the method is a default method, we need to use the def_id of
// the default implementation.
// Having to do this this is really unfortunate.
let method_id = ty::method(self.tcx, method_id).provided_source
.unwrap_or_default(method_id);
let method_id = ty::method(self.tcx, method_id).provided_source.unwrap_or(method_id);
if method_id.crate == LOCAL_CRATE {
let is_private = self.method_is_private(span, method_id.node);

View File

@ -173,7 +173,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path,
fcx.write_error(pat.id);
kind_name = "[error]";
arg_types = (*subpats).clone()
.unwrap_or_default(~[])
.unwrap_or(~[])
.map(|_| ty::mk_err());
}
}
@ -222,7 +222,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path,
fcx.write_error(pat.id);
kind_name = "[error]";
arg_types = (*subpats).clone()
.unwrap_or_default(~[])
.unwrap_or(~[])
.map(|_| ty::mk_err());
}
}

View File

@ -68,7 +68,7 @@ fn fold_crate(
doc::CrateDoc {
topmod: doc::ModDoc {
item: doc::ItemDoc {
name: attrs.name.clone().unwrap_or_default(doc.topmod.name_()),
name: attrs.name.clone().unwrap_or(doc.topmod.name_()),
.. doc.topmod.item.clone()
},
.. doc.topmod.clone()

View File

@ -142,7 +142,7 @@ fn config_from_opts(
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
let output_dir = output_dir.map_move(|s| Path(s));
result::Ok(Config {
output_dir: output_dir.unwrap_or_default(config.output_dir.clone()),
output_dir: output_dir.unwrap_or(config.output_dir.clone()),
.. config
})
};

View File

@ -45,7 +45,7 @@ pub fn capacity<T>(v: @[T]) -> uint {
#[inline]
pub fn build<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> @[A] {
let mut vec = @[];
unsafe { raw::reserve(&mut vec, size.unwrap_or_default(4)); }
unsafe { raw::reserve(&mut vec, size.unwrap_or(4)); }
builder(|x| unsafe { raw::push(&mut vec, x) });
vec
}

View File

@ -332,7 +332,7 @@ impl<T> Option<T> {
/// Returns the contained value or a default
#[inline]
pub fn unwrap_or_default(self, def: T) -> T {
pub fn unwrap_or(self, def: T) -> T {
match self {
Some(x) => x,
None => def

View File

@ -611,7 +611,7 @@ pub fn tmpdir() -> Path {
if cfg!(target_os = "android") {
Path("/data/tmp")
} else {
getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
getenv_nonempty("TMPDIR").unwrap_or(Path("/tmp"))
}
}

View File

@ -205,7 +205,7 @@ pub fn with_capacity<T>(capacity: uint) -> ~[T] {
*/
#[inline]
pub fn build<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> ~[A] {
let mut vec = with_capacity(size.unwrap_or_default(4));
let mut vec = with_capacity(size.unwrap_or(4));
builder(|x| vec.push(x));
vec
}

View File

@ -802,7 +802,7 @@ impl Parser {
*/
let opt_abis = self.parse_opt_abis();
let abis = opt_abis.unwrap_or_default(AbiSet::Rust());
let abis = opt_abis.unwrap_or(AbiSet::Rust());
let purity = self.parse_unsafety();
self.expect_keyword(keywords::Fn);
let (decl, lifetimes) = self.parse_ty_fn_decl();
@ -3461,7 +3461,7 @@ impl Parser {
let ident = self.parse_ident();
let opt_bounds = self.parse_optional_ty_param_bounds();
// For typarams we don't care about the difference b/w "<T>" and "<T:>".
let bounds = opt_bounds.unwrap_or_default(opt_vec::Empty);
let bounds = opt_bounds.unwrap_or(opt_vec::Empty);
ast::TyParam { ident: ident, id: ast::DUMMY_NODE_ID, bounds: bounds }
}
@ -4363,7 +4363,7 @@ impl Parser {
self.obsolete(*self.last_span, ObsoleteExternVisibility);
}
let abis = opt_abis.unwrap_or_default(AbiSet::C());
let abis = opt_abis.unwrap_or(AbiSet::C());
let (inner, next) = self.parse_inner_attrs_and_next();
let m = self.parse_foreign_mod_items(sort, abis, next);
@ -4640,7 +4640,7 @@ impl Parser {
if self.eat_keyword(keywords::Fn) {
// EXTERN FUNCTION ITEM
let abis = opt_abis.unwrap_or_default(AbiSet::C());
let abis = opt_abis.unwrap_or(AbiSet::C());
let (ident, item_, extra_attrs) =
self.parse_item_fn(extern_fn, abis);
return iovi_item(self.mk_item(lo, self.last_span.hi, ident,