Skip to content

Commit d4fe1b3

Browse files
committed
stdlib: Pass getopt matches by alias
1 parent 6c0297c commit d4fe1b3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib/getopts.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,40 +209,40 @@ fn getopts_ivec(args: &str[], opts: &opt[]) -> result {
209209
ret success({opts: opts, vals: vals, free: free});
210210
}
211211

212-
fn opt_vals(m: match, nm: str) -> optval[] {
212+
fn opt_vals(m: &match, nm: str) -> optval[] {
213213
ret alt find_opt(m.opts, mkname(nm)) {
214214
some(id) { m.vals.(id) }
215215
none. { log_err "No option '" + nm + "' defined."; fail }
216216
};
217217
}
218218

219-
fn opt_val(m: match, nm: str) -> optval { ret opt_vals(m, nm).(0); }
219+
fn opt_val(m: &match, nm: str) -> optval { ret opt_vals(m, nm).(0); }
220220

221-
fn opt_present(m: match, nm: str) -> bool {
221+
fn opt_present(m: &match, nm: str) -> bool {
222222
ret ivec::len[optval](opt_vals(m, nm)) > 0u;
223223
}
224224

225-
fn opt_str(m: match, nm: str) -> str {
225+
fn opt_str(m: &match, nm: str) -> str {
226226
ret alt opt_val(m, nm) { val(s) { s } _ { fail } };
227227
}
228228

229-
fn opt_strs(m: match, nm: str) -> vec[str] {
229+
fn opt_strs(m: &match, nm: str) -> vec[str] {
230230
let acc: vec[str] = [];
231231
for v: optval in opt_vals(m, nm) {
232232
alt v { val(s) { acc += [s]; } _ { } }
233233
}
234234
ret acc;
235235
}
236236

237-
fn opt_strs_ivec(m: match, nm: str) -> str[] {
237+
fn opt_strs_ivec(m: &match, nm: str) -> str[] {
238238
let acc: str[] = ~[];
239239
for v: optval in opt_vals(m, nm) {
240240
alt v { val(s) { acc += ~[s]; } _ { } }
241241
}
242242
ret acc;
243243
}
244244

245-
fn opt_maybe_str(m: match, nm: str) -> option::t[str] {
245+
fn opt_maybe_str(m: &match, nm: str) -> option::t[str] {
246246
let vals = opt_vals(m, nm);
247247
if ivec::len[optval](vals) == 0u { ret none[str]; }
248248
ret alt vals.(0) { val(s) { some[str](s) } _ { none[str] } };
@@ -252,7 +252,7 @@ fn opt_maybe_str(m: match, nm: str) -> option::t[str] {
252252
/// Returns none if the option was not present, `def` if the option was
253253
/// present but no argument was provided, and the argument if the option was
254254
/// present and an argument was provided.
255-
fn opt_default(m: match, nm: str, def: str) -> option::t[str] {
255+
fn opt_default(m: &match, nm: str, def: str) -> option::t[str] {
256256
let vals = opt_vals(m, nm);
257257
if ivec::len[optval](vals) == 0u { ret none[str]; }
258258
ret alt vals.(0) { val(s) { some[str](s) } _ { some[str](def) } }

0 commit comments

Comments
 (0)