-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and tools
Description
Blocked on #49162
Example:
Lines 40 to 49 in c19264f
/// ```no_run | |
/// use std::fs::File; | |
/// use std::io::prelude::*; | |
/// | |
/// # fn foo() -> std::io::Result<()> { | |
/// let mut file = File::create("foo.txt")?; | |
/// file.write_all(b"Hello, world!")?; | |
/// # Ok(()) | |
/// # } | |
/// ``` |
Instead of:
use std::fs::File;
use std::io::prelude::*;
# fn foo() -> std::io::Result<()> {
let mut file = File::create("foo.txt")?;
file.write_all(b"Hello, world!")?;
# Ok(())
# }
We can now do:
use std::fs::File;
use std::io::Error;
use std::io::prelude::*;
fn main() -> Result<(), Error> {
let mut file = File::create("foo.txt")?;
file.write_all(b"Hello, world!")?;
Ok(())
}
Which can be copied/pasted straight from the docs such that it will compile, unlike the old example
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and tools