File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,34 @@ macro_rules! try {
349
349
/// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
350
350
/// assert_eq!(v, b"s = \"abc 123\"");
351
351
/// ```
352
+
353
+ /// /// Note : This macro can be used in no_std setups as well
354
+ /// /// In a no_std setup you are responsible for the
355
+ /// /// implementation details of the components.
356
+
357
+ /// ```rust
358
+ /// extern crate core;
359
+ /// use core::fmt::Write;
360
+
361
+ /// #[derive(Debug)]
362
+ /// struct Greetings<'a>{
363
+ /// message : &'a str,
364
+ /// }
365
+
366
+
367
+ /// impl<'a> Write for Greetings<'a>{
368
+ /// fn write_str(&mut self, _s: &str) -> core::fmt::Result {
369
+ /// unimplemented!();
370
+ /// }
371
+ /// }
372
+
373
+ /// fn main(){
374
+ /// let mut m = Greetings{message: ""};
375
+ /// write!(&mut m, "Hello World").expect("Not written");
376
+ /// }
377
+ /// ```
378
+
379
+
352
380
#[ macro_export]
353
381
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
354
382
macro_rules! write {
You can’t perform that action at this time.
0 commit comments