Revert order of arguments to option::maybe and from_maybe

Closes 
This commit is contained in:
Marijn Haverbeke 2012-03-20 14:55:07 +01:00
parent 1547c27926
commit 7a34ac5890
9 changed files with 12 additions and 12 deletions
src
libcore
rustc
driver
metadata
middle
syntax/parse
rustdoc

@ -52,13 +52,13 @@ pure fn is_some<T>(opt: option<T>) -> bool {
!is_none(opt)
}
pure fn from_maybe<T: copy>(def: T, opt: option<T>) -> T {
pure fn from_maybe<T: copy>(opt: option<T>, def: T) -> T {
#[doc = "Returns the contained value or a default"];
alt opt { some(x) { x } none { def } }
}
fn maybe<T, U: copy>(def: U, opt: option<T>, f: fn(T) -> U) -> U {
fn maybe<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
#[doc = "Applies a function to the contained value or returns a default"];
alt opt { none { def } some(t) { f(t) } }

@ -372,7 +372,7 @@ fn homedir() -> option<path> {
#[cfg(target_os = "win32")]
fn secondary() -> option<path> {
option::maybe(none, getenv("USERPROFILE")) {|p|
option::chain(getenv("USERPROFILE")) {|p|
if !str::is_empty(p) {
some(p)
} else {

@ -245,7 +245,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
option::may (sp.expn_info) {|ei|
let ss = option::maybe("", ei.callie.span,
let ss = option::maybe(ei.callie.span, "",
bind codemap::span_to_str(_, cm));
print_diagnostic(ss, note,
#fmt("in expansion of #%s", ei.callie.name));

@ -163,7 +163,7 @@ fn get_dep_hashes(cstore: cstore) -> [str] {
fn get_path(cstore: cstore, d: ast::def_id) -> [str] {
// let f = bind str::split_str(_, "::");
option::maybe([], p(cstore).mod_path_map.find(d),
option::maybe(p(cstore).mod_path_map.find(d), [],
{|ds| str::split_str(ds, "::")})
}
// Local Variables:

@ -616,7 +616,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
handle_fail(fcx, pres, post);
ret set_prestate_ann(fcx.ccx, e.id, pres) |
set_poststate_ann(fcx.ccx, e.id, post) |
option::maybe(false, maybe_fail_val, {|fail_val|
option::maybe(maybe_fail_val, false, {|fail_val|
find_pre_post_state_expr(fcx, pres, fail_val)});
}
expr_assert(p) {

@ -356,7 +356,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
region_map: @middle::region::region_map) -> ctxt {
let interner = map::hashmap({|&&k: intern_key|
hash_type_structure(k.struct) +
option::maybe(0u, k.o_def_id, ast_util::hash_def_id)
option::maybe(k.o_def_id, 0u, ast_util::hash_def_id)
}, {|&&a, &&b| a == b});
@{interner: interner,
mutable next_id: 0u,

@ -25,7 +25,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
-> (ast::_mod, [ast::attribute]) {
#debug("eval crate prefix: %s", prefix);
#debug("eval crate suffix: %s",
option::from_maybe("none", suffix));
option::from_maybe(suffix, "none"));
let (cview_items, citems, cattrs)
= parse_companion_mod(cx, prefix, suffix);
let view_items: [@ast::view_item] = [];

@ -50,7 +50,7 @@ fn fold_crate(
{
topmod: {
item: {
name: option::from_maybe(doc.topmod.name(), attrs.name)
name: option::from_maybe(attrs.name, doc.topmod.name())
with doc.topmod.item
}
with doc.topmod

@ -125,14 +125,14 @@ fn config_from_opts(
let result = result::chain(result) {|config|
let output_dir = getopts::opt_maybe_str(match, opt_output_dir());
result::ok({
output_dir: option::from_maybe(config.output_dir, output_dir)
output_dir: option::from_maybe(output_dir, config.output_dir)
with config
})
};
let result = result::chain(result) {|config|
let output_format = getopts::opt_maybe_str(
match, opt_output_format());
option::maybe(result::ok(config), output_format) {|output_format|
option::maybe(output_format, result::ok(config)) {|output_format|
result::chain(parse_output_format(output_format)) {|output_format|
result::ok({
output_format: output_format
@ -143,7 +143,7 @@ fn config_from_opts(
};
let result = result::chain(result) {|config|
let output_style = getopts::opt_maybe_str(match, opt_output_style());
option::maybe(result::ok(config), output_style) {|output_style|
option::maybe(output_style, result::ok(config)) {|output_style|
result::chain(parse_output_style(output_style)) {|output_style|
result::ok({
output_style: output_style