Skip to content

Commit 0ba8ccd

Browse files
committed
rm obsolete float to_str_radix free functions
1 parent 46fc549 commit 0ba8ccd

File tree

3 files changed

+53
-74
lines changed

3 files changed

+53
-74
lines changed

src/libstd/num/f32.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -740,29 +740,6 @@ pub fn to_str_hex(num: f32) -> ~str {
740740
r
741741
}
742742

743-
///
744-
/// Converts a float to a string in a given radix
745-
///
746-
/// # Arguments
747-
///
748-
/// * num - The float value
749-
/// * radix - The base to use
750-
///
751-
/// # Failure
752-
///
753-
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
754-
/// possible misinterpretation of the result at higher bases. If those values
755-
/// are expected, use `to_str_radix_special()` instead.
756-
///
757-
#[inline]
758-
pub fn to_str_radix(num: f32, rdx: uint) -> ~str {
759-
let (r, special) = strconv::float_to_str_common(
760-
num, rdx, true, strconv::SignNeg, strconv::DigAll);
761-
if special { fail!("number has a special value, \
762-
try to_str_radix_special() if those are expected") }
763-
r
764-
}
765-
766743
///
767744
/// Converts a float to a string in a given radix, and a flag indicating
768745
/// whether it's a special value
@@ -816,9 +793,25 @@ impl to_str::ToStr for f32 {
816793
}
817794

818795
impl num::ToStrRadix for f32 {
796+
/// Converts a float to a string in a given radix
797+
///
798+
/// # Arguments
799+
///
800+
/// * num - The float value
801+
/// * radix - The base to use
802+
///
803+
/// # Failure
804+
///
805+
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
806+
/// possible misinterpretation of the result at higher bases. If those values
807+
/// are expected, use `to_str_radix_special()` instead.
819808
#[inline]
820809
fn to_str_radix(&self, rdx: uint) -> ~str {
821-
to_str_radix(*self, rdx)
810+
let (r, special) = strconv::float_to_str_common(
811+
*self, rdx, true, strconv::SignNeg, strconv::DigAll);
812+
if special { fail!("number has a special value, \
813+
try to_str_radix_special() if those are expected") }
814+
r
822815
}
823816
}
824817

src/libstd/num/f64.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -787,29 +787,6 @@ pub fn to_str_hex(num: f64) -> ~str {
787787
r
788788
}
789789

790-
///
791-
/// Converts a float to a string in a given radix
792-
///
793-
/// # Arguments
794-
///
795-
/// * num - The float value
796-
/// * radix - The base to use
797-
///
798-
/// # Failure
799-
///
800-
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
801-
/// possible misinterpretation of the result at higher bases. If those values
802-
/// are expected, use `to_str_radix_special()` instead.
803-
///
804-
#[inline]
805-
pub fn to_str_radix(num: f64, rdx: uint) -> ~str {
806-
let (r, special) = strconv::float_to_str_common(
807-
num, rdx, true, strconv::SignNeg, strconv::DigAll);
808-
if special { fail!("number has a special value, \
809-
try to_str_radix_special() if those are expected") }
810-
r
811-
}
812-
813790
///
814791
/// Converts a float to a string in a given radix, and a flag indicating
815792
/// whether it's a special value
@@ -863,9 +840,25 @@ impl to_str::ToStr for f64 {
863840
}
864841

865842
impl num::ToStrRadix for f64 {
843+
/// Converts a float to a string in a given radix
844+
///
845+
/// # Arguments
846+
///
847+
/// * num - The float value
848+
/// * radix - The base to use
849+
///
850+
/// # Failure
851+
///
852+
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
853+
/// possible misinterpretation of the result at higher bases. If those values
854+
/// are expected, use `to_str_radix_special()` instead.
866855
#[inline]
867856
fn to_str_radix(&self, rdx: uint) -> ~str {
868-
to_str_radix(*self, rdx)
857+
let (r, special) = strconv::float_to_str_common(
858+
*self, rdx, true, strconv::SignNeg, strconv::DigAll);
859+
if special { fail!("number has a special value, \
860+
try to_str_radix_special() if those are expected") }
861+
r
869862
}
870863
}
871864

src/libstd/num/float.rs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,6 @@ pub fn to_str_hex(num: float) -> ~str {
111111
r
112112
}
113113

114-
///
115-
/// Converts a float to a string in a given radix
116-
///
117-
/// # Arguments
118-
///
119-
/// * num - The float value
120-
/// * radix - The base to use
121-
///
122-
/// # Failure
123-
///
124-
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
125-
/// possible misinterpretation of the result at higher bases. If those values
126-
/// are expected, use `to_str_radix_special()` instead.
127-
///
128-
#[inline]
129-
pub fn to_str_radix(num: float, radix: uint) -> ~str {
130-
let (r, special) = strconv::float_to_str_common(
131-
num, radix, true, strconv::SignNeg, strconv::DigAll);
132-
if special { fail!("number has a special value, \
133-
try to_str_radix_special() if those are expected") }
134-
r
135-
}
136-
137114
///
138115
/// Converts a float to a string in a given radix, and a flag indicating
139116
/// whether it's a special value
@@ -187,9 +164,25 @@ impl to_str::ToStr for float {
187164
}
188165

189166
impl num::ToStrRadix for float {
167+
/// Converts a float to a string in a given radix
168+
///
169+
/// # Arguments
170+
///
171+
/// * num - The float value
172+
/// * radix - The base to use
173+
///
174+
/// # Failure
175+
///
176+
/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to
177+
/// possible misinterpretation of the result at higher bases. If those values
178+
/// are expected, use `to_str_radix_special()` instead.
190179
#[inline]
191180
fn to_str_radix(&self, radix: uint) -> ~str {
192-
to_str_radix(*self, radix)
181+
let (r, special) = strconv::float_to_str_common(
182+
*self, radix, true, strconv::SignNeg, strconv::DigAll);
183+
if special { fail!("number has a special value, \
184+
try to_str_radix_special() if those are expected") }
185+
r
193186
}
194187
}
195188

@@ -1342,8 +1335,8 @@ mod tests {
13421335
13431336
#[test]
13441337
pub fn test_to_str_radix() {
1345-
assert_eq!(to_str_radix(36., 36u), ~"10");
1346-
assert_eq!(to_str_radix(8.125, 2u), ~"1000.001");
1338+
assert_eq!(36.0f.to_str_radix(36u), ~"10");
1339+
assert_eq!(8.125f.to_str_radix(2u), ~"1000.001");
13471340
}
13481341
13491342
#[test]

0 commit comments

Comments
 (0)