about summary refs log tree commit diff
path: root/src/libnum/complex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnum/complex.rs')
-rw-r--r--src/libnum/complex.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libnum/complex.rs b/src/libnum/complex.rs
index 3755b2e43af..5ffd23aa346 100644
--- a/src/libnum/complex.rs
+++ b/src/libnum/complex.rs
@@ -11,6 +11,7 @@
 
 //! Complex numbers.
 
+use std::fmt;
 use std::num::{Zero,One,ToStrRadix};
 
 // FIXME #1284: handle complex NaN & infinity etc. This
@@ -167,12 +168,12 @@ impl<T: Clone + Num> One for Cmplx<T> {
 }
 
 /* string conversions */
-impl<T: ToStr + Num + Ord> ToStr for Cmplx<T> {
-    fn to_str(&self) -> ~str {
+impl<T: fmt::Show + Num + Ord> fmt::Show for Cmplx<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.im < Zero::zero() {
-            format!("{}-{}i", self.re.to_str(), (-self.im).to_str())
+            write!(f.buf, "{}-{}i", self.re, -self.im)
         } else {
-            format!("{}+{}i", self.re.to_str(), self.im.to_str())
+            write!(f.buf, "{}+{}i", self.re, self.im)
         }
     }
 }