summary refs log tree commit diff
path: root/src/libcore/fmt
diff options
context:
space:
mode:
authorJake Goulding <jake.goulding@gmail.com>2016-05-06 09:31:11 -0400
committerJake Goulding <jake.goulding@gmail.com>2016-05-19 13:55:13 -0400
commitbc7595c8abbf4e3b737e926d61814686e0ebda77 (patch)
tree3ead763b6c18622639409543dc3a46ba1e6374c1 /src/libcore/fmt
parent2fb6f8e2c94a7041877ed8460f2621974c5233f7 (diff)
downloadrust-bc7595c8abbf4e3b737e926d61814686e0ebda77.tar.gz
rust-bc7595c8abbf4e3b737e926d61814686e0ebda77.zip
Support 16-bit pointers as well as i/usize
This is based on the original work of Dylan McKay for the
[avr-rust project][ar].

[ar]: https://github.com/avr-rust/rust
Diffstat (limited to 'src/libcore/fmt')
-rw-r--r--src/libcore/fmt/num.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs
index a944c996c1a..d55e0317a94 100644
--- a/src/libcore/fmt/num.rs
+++ b/src/libcore/fmt/num.rs
@@ -29,6 +29,7 @@ trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
            Sub<Output=Self> + Copy {
     fn from_u8(u: u8) -> Self;
     fn to_u8(&self) -> u8;
+    fn to_u16(&self) -> u16;
     fn to_u32(&self) -> u32;
     fn to_u64(&self) -> u64;
 }
@@ -37,6 +38,7 @@ macro_rules! doit {
     ($($t:ident)*) => ($(impl Int for $t {
         fn from_u8(u: u8) -> $t { u as $t }
         fn to_u8(&self) -> u8 { *self as u8 }
+        fn to_u16(&self) -> u16 { *self as u16 }
         fn to_u32(&self) -> u32 { *self as u32 }
         fn to_u64(&self) -> u64 { *self as u64 }
     })*)
@@ -256,6 +258,8 @@ macro_rules! impl_Display {
 
 impl_Display!(i8, u8, i16, u16, i32, u32: to_u32);
 impl_Display!(i64, u64: to_u64);
+#[cfg(target_pointer_width = "16")]
+impl_Display!(isize, usize: to_u16);
 #[cfg(target_pointer_width = "32")]
 impl_Display!(isize, usize: to_u32);
 #[cfg(target_pointer_width = "64")]