Skip to content

Commit 7a34ac5

Browse files
committed
Revert order of arguments to option::maybe and from_maybe
Closes #2019
1 parent 1547c27 commit 7a34ac5

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ pure fn is_some<T>(opt: option<T>) -> bool {
5252
!is_none(opt)
5353
}
5454

55-
pure fn from_maybe<T: copy>(def: T, opt: option<T>) -> T {
55+
pure fn from_maybe<T: copy>(opt: option<T>, def: T) -> T {
5656
#[doc = "Returns the contained value or a default"];
5757

5858
alt opt { some(x) { x } none { def } }
5959
}
6060

61-
fn maybe<T, U: copy>(def: U, opt: option<T>, f: fn(T) -> U) -> U {
61+
fn maybe<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
6262
#[doc = "Applies a function to the contained value or returns a default"];
6363

6464
alt opt { none { def } some(t) { f(t) } }

src/libcore/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ fn homedir() -> option<path> {
372372

373373
#[cfg(target_os = "win32")]
374374
fn secondary() -> option<path> {
375-
option::maybe(none, getenv("USERPROFILE")) {|p|
375+
option::chain(getenv("USERPROFILE")) {|p|
376376
if !str::is_empty(p) {
377377
some(p)
378378
} else {

src/rustc/driver/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
245245

246246
fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
247247
option::may (sp.expn_info) {|ei|
248-
let ss = option::maybe("", ei.callie.span,
248+
let ss = option::maybe(ei.callie.span, "",
249249
bind codemap::span_to_str(_, cm));
250250
print_diagnostic(ss, note,
251251
#fmt("in expansion of #%s", ei.callie.name));

src/rustc/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn get_dep_hashes(cstore: cstore) -> [str] {
163163

164164
fn get_path(cstore: cstore, d: ast::def_id) -> [str] {
165165
// let f = bind str::split_str(_, "::");
166-
option::maybe([], p(cstore).mod_path_map.find(d),
166+
option::maybe(p(cstore).mod_path_map.find(d), [],
167167
{|ds| str::split_str(ds, "::")})
168168
}
169169
// Local Variables:

src/rustc/middle/tstate/states.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
616616
handle_fail(fcx, pres, post);
617617
ret set_prestate_ann(fcx.ccx, e.id, pres) |
618618
set_poststate_ann(fcx.ccx, e.id, post) |
619-
option::maybe(false, maybe_fail_val, {|fail_val|
619+
option::maybe(maybe_fail_val, false, {|fail_val|
620620
find_pre_post_state_expr(fcx, pres, fail_val)});
621621
}
622622
expr_assert(p) {

src/rustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
356356
region_map: @middle::region::region_map) -> ctxt {
357357
let interner = map::hashmap({|&&k: intern_key|
358358
hash_type_structure(k.struct) +
359-
option::maybe(0u, k.o_def_id, ast_util::hash_def_id)
359+
option::maybe(k.o_def_id, 0u, ast_util::hash_def_id)
360360
}, {|&&a, &&b| a == b});
361361
@{interner: interner,
362362
mutable next_id: 0u,

src/rustc/syntax/parse/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
2525
-> (ast::_mod, [ast::attribute]) {
2626
#debug("eval crate prefix: %s", prefix);
2727
#debug("eval crate suffix: %s",
28-
option::from_maybe("none", suffix));
28+
option::from_maybe(suffix, "none"));
2929
let (cview_items, citems, cattrs)
3030
= parse_companion_mod(cx, prefix, suffix);
3131
let view_items: [@ast::view_item] = [];

src/rustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn fold_crate(
5050
{
5151
topmod: {
5252
item: {
53-
name: option::from_maybe(doc.topmod.name(), attrs.name)
53+
name: option::from_maybe(attrs.name, doc.topmod.name())
5454
with doc.topmod.item
5555
}
5656
with doc.topmod

src/rustdoc/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ fn config_from_opts(
125125
let result = result::chain(result) {|config|
126126
let output_dir = getopts::opt_maybe_str(match, opt_output_dir());
127127
result::ok({
128-
output_dir: option::from_maybe(config.output_dir, output_dir)
128+
output_dir: option::from_maybe(output_dir, config.output_dir)
129129
with config
130130
})
131131
};
132132
let result = result::chain(result) {|config|
133133
let output_format = getopts::opt_maybe_str(
134134
match, opt_output_format());
135-
option::maybe(result::ok(config), output_format) {|output_format|
135+
option::maybe(output_format, result::ok(config)) {|output_format|
136136
result::chain(parse_output_format(output_format)) {|output_format|
137137
result::ok({
138138
output_format: output_format
@@ -143,7 +143,7 @@ fn config_from_opts(
143143
};
144144
let result = result::chain(result) {|config|
145145
let output_style = getopts::opt_maybe_str(match, opt_output_style());
146-
option::maybe(result::ok(config), output_style) {|output_style|
146+
option::maybe(output_style, result::ok(config)) {|output_style|
147147
result::chain(parse_output_style(output_style)) {|output_style|
148148
result::ok({
149149
output_style: output_style

0 commit comments

Comments
 (0)