about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnumOpus21 <sivaauturic@gmail.com>2018-08-11 14:43:50 -0400
committerSiva Prasad <sivauturic@gmail.com>2018-09-05 08:56:00 -0400
commit2ae2c628eec74b78d691c2df7a1eccbe9cbd0a72 (patch)
tree1a4487244898b99fa72bb3852c9af564ed5da0b7 /src
parentb0297f3043e4ed592c63c0bcc11df3655ec8cf46 (diff)
downloadrust-2ae2c628eec74b78d691c2df7a1eccbe9cbd0a72.tar.gz
rust-2ae2c628eec74b78d691c2df7a1eccbe9cbd0a72.zip
Updated libcore/macro.rs to note write macro can work in no_std setups
Diffstat (limited to 'src')
-rw-r--r--src/libcore/macros.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 0032bedc7ed..4bf5a6302bc 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -349,6 +349,34 @@ macro_rules! try {
 /// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
 /// assert_eq!(v, b"s = \"abc 123\"");
 /// ```
+
+/// /// Note : This macro can be used in no_std setups as well
+/// /// In a no_std setup you are responsible for the 
+/// /// implementation details of the components.
+
+/// ```rust
+///  extern crate core;
+///  use core::fmt::Write;
+
+///  #[derive(Debug)]
+///  struct Greetings<'a>{
+///      message : &'a str,
+///  }
+
+
+///  impl<'a> Write for Greetings<'a>{
+///      fn write_str(&mut self, _s: &str) -> core::fmt::Result {
+///           unimplemented!();
+///      }
+///  }
+
+///  fn main(){
+///      let mut m = Greetings{message: ""};
+///      write!(&mut m, "Hello World").expect("Not written");
+///  }
+/// ```
+
+
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! write {