Skip to content

Commit 9e5a416

Browse files
committed
fmt: simplify parse_conversion
1 parent af298de commit 9e5a416

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/libcore/extfmt.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,19 @@ pub mod ct {
214214
err: ErrorFn) ->
215215
Parsed<Piece> {
216216
let parm = parse_parameter(s, i, lim);
217-
let flags = parse_flags(s, parm.next, lim);
218-
let width = parse_count(s, flags.next, lim);
217+
// avoid copying ~[Flag] by destructuring
218+
let Parsed {val: flags_val, next: flags_next} = parse_flags(s,
219+
parm.next, lim);
220+
let width = parse_count(s, flags_next, lim);
219221
let prec = parse_precision(s, width.next, lim);
220222
let ty = parse_type(s, prec.next, lim, err);
221-
return Parsed::new(
223+
Parsed::new(
222224
PieceConv(Conv {param: parm.val,
223-
flags: copy flags.val,
225+
flags: flags_val,
224226
width: width.val,
225227
precision: prec.val,
226228
ty: ty.val}),
227-
ty.next);
229+
ty.next)
228230
}
229231
pub fn parse_parameter(s: &str, i: uint, lim: uint) ->
230232
Parsed<Option<uint>> {

0 commit comments

Comments
 (0)