Skip to content

Commit c7b6eb3

Browse files
author
Jorge Aparicio
committed
libcore: use unboxed closures in float_to_str_bytes_common
1 parent 5579692 commit c7b6eb3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libcore/fmt/float.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use fmt;
2020
use iter::{range, DoubleEndedIteratorExt};
2121
use num::{Float, FPNaN, FPInfinite, ToPrimitive};
2222
use num::cast;
23+
use ops::FnOnce;
2324
use result::Result::Ok;
2425
use slice::{mod, SlicePrelude};
2526
use str::StrPrelude;
@@ -84,16 +85,18 @@ static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
8485
/// between digit and exponent sign `'e'`.
8586
/// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
8687
/// between digit and exponent sign `'p'`.
87-
pub fn float_to_str_bytes_common<T: Float, U>(
88+
pub fn float_to_str_bytes_common<T: Float, U, F>(
8889
num: T,
8990
radix: uint,
9091
negative_zero: bool,
9192
sign: SignFormat,
9293
digits: SignificantDigits,
9394
exp_format: ExponentFormat,
9495
exp_upper: bool,
95-
f: |&[u8]| -> U
96-
) -> U {
96+
f: F
97+
) -> U where
98+
F: FnOnce(&[u8]) -> U,
99+
{
97100
assert!(2 <= radix && radix <= 36);
98101
match exp_format {
99102
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'

0 commit comments

Comments
 (0)