More questionmarks in doctests
This commit is contained in:
parent
ec30876f30
commit
cbac7815fe
1 changed files with 27 additions and 16 deletions
|
@ -353,11 +353,15 @@ macro_rules! r#try {
|
||||||
/// use std::fmt::Write as FmtWrite;
|
/// use std::fmt::Write as FmtWrite;
|
||||||
/// use std::io::Write as IoWrite;
|
/// use std::io::Write as IoWrite;
|
||||||
///
|
///
|
||||||
/// let mut s = String::new();
|
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut v = Vec::new();
|
/// let mut s = String::new();
|
||||||
/// write!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
|
/// let mut v = Vec::new();
|
||||||
/// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
|
///
|
||||||
/// assert_eq!(v, b"s = \"abc 123\"");
|
/// write!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
|
||||||
|
/// write!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
|
||||||
|
/// assert_eq!(v, b"s = \"abc 123\"");
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Note: This macro can be used in `no_std` setups as well.
|
/// Note: This macro can be used in `no_std` setups as well.
|
||||||
|
@ -399,14 +403,17 @@ macro_rules! write {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::io::Write;
|
/// use std::io::{Write, Result};
|
||||||
///
|
///
|
||||||
/// let mut w = Vec::new();
|
/// fn main() -> Result<()> {
|
||||||
/// writeln!(&mut w).unwrap();
|
/// let mut w = Vec::new();
|
||||||
/// writeln!(&mut w, "test").unwrap();
|
/// writeln!(&mut w)?;
|
||||||
/// writeln!(&mut w, "formatted {}", "arguments").unwrap();
|
/// writeln!(&mut w, "test")?;
|
||||||
|
/// writeln!(&mut w, "formatted {}", "arguments")?;
|
||||||
///
|
///
|
||||||
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
|
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
|
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
|
||||||
|
@ -417,11 +424,15 @@ macro_rules! write {
|
||||||
/// use std::fmt::Write as FmtWrite;
|
/// use std::fmt::Write as FmtWrite;
|
||||||
/// use std::io::Write as IoWrite;
|
/// use std::io::Write as IoWrite;
|
||||||
///
|
///
|
||||||
/// let mut s = String::new();
|
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let mut v = Vec::new();
|
/// let mut s = String::new();
|
||||||
/// writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
|
/// let mut v = Vec::new();
|
||||||
/// writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
|
///
|
||||||
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
|
/// writeln!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
|
||||||
|
/// writeln!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
|
||||||
|
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue