Refined the example
This commit is contained in:
parent
2ae2c628ee
commit
3ae6d06edb
1 changed files with 10 additions and 22 deletions
|
@ -349,34 +349,22 @@ 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;
|
||||
/// 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.
|
||||
/// ```
|
||||
/// # extern crate core;
|
||||
/// use core::fmt::Write;
|
||||
|
||||
/// #[derive(Debug)]
|
||||
/// struct Greetings<'a>{
|
||||
/// message : &'a str,
|
||||
/// struct Example{
|
||||
/// }
|
||||
|
||||
|
||||
/// impl<'a> Write for Greetings<'a>{
|
||||
/// impl Write for Example{
|
||||
/// fn write_str(&mut self, _s: &str) -> core::fmt::Result {
|
||||
/// unimplemented!();
|
||||
/// }
|
||||
/// }
|
||||
|
||||
/// fn main(){
|
||||
/// let mut m = Greetings{message: ""};
|
||||
/// let mut m = Example{};
|
||||
/// write!(&mut m, "Hello World").expect("Not written");
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
|
||||
#[macro_export]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
macro_rules! write {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue