about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-03-13 14:08:15 +0100
committerSimon Sapin <simon.sapin@exyr.org>2018-03-13 14:53:06 +0100
commit4897935e8645e5f1d9d9ef61c78a1cb019c44f89 (patch)
treed32522f913ff690cfe6893ffe68d04d0ca2c2008 /src/liballoc
parent883e74645d350b6752cb94d48f46363f6f8789e9 (diff)
downloadrust-4897935e8645e5f1d9d9ef61c78a1cb019c44f89.tar.gz
rust-4897935e8645e5f1d9d9ef61c78a1cb019c44f89.zip
Add hexadecimal formatting of integers with fmt::Debug
This can be used for integers within a larger types which implements Debug
(possibly through derive) but not fmt::UpperHex or fmt::LowerHex.

```rust
assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]");
assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]");
```

RFC: https://github.com/rust-lang/rfcs/pull/2226
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/fmt.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs
index a092bfb3b0a..2c4cdef03b0 100644
--- a/src/liballoc/fmt.rs
+++ b/src/liballoc/fmt.rs
@@ -113,6 +113,8 @@
 //!
 //! * *nothing* ⇒ [`Display`]
 //! * `?` ⇒ [`Debug`]
+//! * `x?` ⇒ [`Debug`] with lower-case hexadecimal integers
+//! * `X?` ⇒ [`Debug`] with lower-case hexadecimal integers
 //! * `o` ⇒ [`Octal`](trait.Octal.html)
 //! * `x` ⇒ [`LowerHex`](trait.LowerHex.html)
 //! * `X` ⇒ [`UpperHex`](trait.UpperHex.html)