Skip to content

Commit

Permalink
Merge pull request 1737 from nyurik/doc-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 23, 2024
2 parents ff45b6a + a82867c commit 69fadff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ ast_struct! {
///
/// ```
/// use std::env;
/// use std::fs::File;
/// use std::io::Read;
/// use std::fs::read_to_string;
/// use std::process;
///
/// fn main() {
Expand All @@ -34,11 +33,7 @@ ast_struct! {
/// }
/// };
///
/// let mut file = File::open(&filename).expect("unable to open file");
///
/// let mut src = String::new();
/// file.read_to_string(&mut src).expect("unable to read file");
///
/// let src = read_to_string(&filename).expect("unable to read file");
/// let syntax = syn::parse_file(&src).expect("unable to parse file");
///
/// // Debug impl is available if Syn is built with "extra-traits" feature.
Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,14 +973,11 @@ pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> {
///
/// ```no_run
/// use std::error::Error;
/// use std::fs::File;
/// use std::fs::read_to_string;
/// use std::io::Read;
///
/// fn run() -> Result<(), Box<dyn Error>> {
/// let mut file = File::open("path/to/code.rs")?;
/// let mut content = String::new();
/// file.read_to_string(&mut content)?;
///
/// let content = read_to_string("path/to/code.rs")?;
/// let ast = syn::parse_file(&content)?;
/// if let Some(shebang) = ast.shebang {
/// println!("{}", shebang);
Expand Down

0 comments on commit 69fadff

Please sign in to comment.