Rename option::get_or_default to get_default, for consistency
This commit is contained in:
parent
9280d0c090
commit
1c39fda0ea
@ -52,7 +52,7 @@ pure fn is_some<T>(opt: option<T>) -> bool {
|
|||||||
!is_none(opt)
|
!is_none(opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn get_or_default<T: copy>(opt: option<T>, def: T) -> T {
|
pure fn get_default<T: copy>(opt: option<T>, def: T) -> T {
|
||||||
#[doc = "Returns the contained value or a default"];
|
#[doc = "Returns the contained value or a default"];
|
||||||
|
|
||||||
alt opt { some(x) { x } none { def } }
|
alt opt { some(x) { x } none { def } }
|
||||||
@ -94,7 +94,7 @@ impl extensions<T:copy> for option<T> {
|
|||||||
"]
|
"]
|
||||||
fn chain<U>(f: fn(T) -> option<U>) -> option<U> { chain(self, f) }
|
fn chain<U>(f: fn(T) -> option<U>) -> option<U> { chain(self, f) }
|
||||||
#[doc = "Returns the contained value or a default"]
|
#[doc = "Returns the contained value or a default"]
|
||||||
fn get_or_default(def: T) -> T { get_or_default(self, def) }
|
fn get_default(def: T) -> T { get_default(self, def) }
|
||||||
#[doc = "Applies a function to the contained value or returns a default"]
|
#[doc = "Applies a function to the contained value or returns a default"]
|
||||||
fn map_default<U: copy>(def: U, f: fn(T) -> U) -> U
|
fn map_default<U: copy>(def: U, f: fn(T) -> U) -> U
|
||||||
{ map_default(self, def, f) }
|
{ map_default(self, def, f) }
|
||||||
|
@ -22,7 +22,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
|
|||||||
-> (ast::_mod, [ast::attribute]) {
|
-> (ast::_mod, [ast::attribute]) {
|
||||||
#debug("eval crate prefix: %s", prefix);
|
#debug("eval crate prefix: %s", prefix);
|
||||||
#debug("eval crate suffix: %s",
|
#debug("eval crate suffix: %s",
|
||||||
option::get_or_default(suffix, "none"));
|
option::get_default(suffix, "none"));
|
||||||
let (cview_items, citems, cattrs)
|
let (cview_items, citems, cattrs)
|
||||||
= parse_companion_mod(cx, prefix, suffix);
|
= parse_companion_mod(cx, prefix, suffix);
|
||||||
let mut view_items: [@ast::view_item] = [];
|
let mut view_items: [@ast::view_item] = [];
|
||||||
|
@ -2017,7 +2017,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
|
|||||||
// ctors don't have attrs, at least not right now
|
// ctors don't have attrs, at least not right now
|
||||||
let tp_tys: [ty::t] = ty::ty_params_to_tys(ccx.tcx, tps);
|
let tp_tys: [ty::t] = ty::ty_params_to_tys(ccx.tcx, tps);
|
||||||
trans_class_ctor(ccx, pt, ctor.node.dec, ctor.node.body, lldecl,
|
trans_class_ctor(ccx, pt, ctor.node.dec, ctor.node.body, lldecl,
|
||||||
option::get_or_default(psubsts,
|
option::get_default(psubsts,
|
||||||
{tys:tp_tys, vtables: none, bounds: @[]}),
|
{tys:tp_tys, vtables: none, bounds: @[]}),
|
||||||
fn_id.node, parent_id, ctor.span);
|
fn_id.node, parent_id, ctor.span);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ fn fold_crate(
|
|||||||
{
|
{
|
||||||
topmod: {
|
topmod: {
|
||||||
item: {
|
item: {
|
||||||
name: option::get_or_default(attrs.name, doc.topmod.name())
|
name: option::get_default(attrs.name, doc.topmod.name())
|
||||||
with doc.topmod.item
|
with doc.topmod.item
|
||||||
}
|
}
|
||||||
with doc.topmod
|
with doc.topmod
|
||||||
|
@ -125,7 +125,7 @@ fn config_from_opts(
|
|||||||
let result = result::chain(result) {|config|
|
let result = result::chain(result) {|config|
|
||||||
let output_dir = getopts::opt_maybe_str(match, opt_output_dir());
|
let output_dir = getopts::opt_maybe_str(match, opt_output_dir());
|
||||||
result::ok({
|
result::ok({
|
||||||
output_dir: option::get_or_default(output_dir, config.output_dir)
|
output_dir: option::get_default(output_dir, config.output_dir)
|
||||||
with config
|
with config
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user