Skip to content

Commit

Permalink
Merge pull request #106 from H2CO3/default-tokenstream
Browse files Browse the repository at this point in the history
impl Default for TokenStream
  • Loading branch information
alexcrichton authored Jul 15, 2018
2 parents b761e47 + 4f74b68 commit 32f2043
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ impl TokenStream {
}
}

/// `TokenStream::default()` returns an empty stream,
/// i.e. this is equivalent with `TokenStream::new()`.
impl Default for TokenStream {
fn default() -> Self {
TokenStream::new()
}
}

/// Attempts to break the string into tokens and parse those tokens into a token
/// stream.
///
Expand Down
7 changes: 7 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,10 @@ TokenStream [

assert_eq!(expected, format!("{:#?}", tts));
}

#[test]
fn default_tokenstream_is_empty() {
let default_token_stream: TokenStream = Default::default();

assert!(default_token_stream.is_empty());
}

0 comments on commit 32f2043

Please sign in to comment.