Rename and make public ParseStream::step
diff --git a/src/group.rs b/src/group.rs
index 1f46f2b..9c44b7a 100644
--- a/src/group.rs
+++ b/src/group.rs
@@ -26,7 +26,7 @@
impl<'a> ParseBuffer<'a> {
fn parse_delimited(&self, delimiter: Delimiter) -> Result<(Span, ParseBuffer<'a>)> {
- self.step_cursor(|cursor| {
+ self.step(|cursor| {
if let Some((content, span, rest)) = cursor.group(delimiter) {
let content =
ParseBuffer::new(span, cursor.advance(content), self.get_unexpected());
diff --git a/src/lit.rs b/src/lit.rs
index 51ade4b..ce3e163 100644
--- a/src/lit.rs
+++ b/src/lit.rs
@@ -436,7 +436,7 @@
impl Parse for Lit {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| match cursor.literal() {
+ input.step(|cursor| match cursor.literal() {
Some((lit, rest)) => Ok((Lit::new(lit), rest)),
_ => match cursor.ident() {
Some((ident, rest)) => Ok((
diff --git a/src/mac.rs b/src/mac.rs
index b08c8a1..4bffb55 100644
--- a/src/mac.rs
+++ b/src/mac.rs
@@ -72,7 +72,7 @@
#[cfg(feature = "parsing")]
pub fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStream)> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
if let Some((TokenTree::Group(g), rest)) = cursor.token_tree() {
let span = g.span();
let delimiter = match g.delimiter() {
diff --git a/src/parse.rs b/src/parse.rs
index 0570e2d..47b2a10 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -115,7 +115,7 @@
}
let ahead = self.fork();
ahead
- .step_cursor(|cursor| Ok(cursor.token_tree().unwrap()))
+ .step(|cursor| Ok(cursor.token_tree().unwrap()))
.unwrap();
ahead.peek(token)
}
@@ -126,10 +126,10 @@
}
let ahead = self.fork();
ahead
- .step_cursor(|cursor| Ok(cursor.token_tree().unwrap()))
+ .step(|cursor| Ok(cursor.token_tree().unwrap()))
.unwrap();
ahead
- .step_cursor(|cursor| Ok(cursor.token_tree().unwrap()))
+ .step(|cursor| Ok(cursor.token_tree().unwrap()))
.unwrap();
ahead.peek(token)
}
@@ -156,9 +156,7 @@
error::new_at(self.scope, self.cursor(), message)
}
- // Not public API.
- #[doc(hidden)]
- pub fn step_cursor<F, R>(&self, function: F) -> Result<R>
+ pub fn step<F, R>(&self, function: F) -> Result<R>
where
F: for<'c> FnOnce(StepCursor<'c, 'a>) -> Result<(R, Cursor<'c>)>,
{
@@ -194,7 +192,7 @@
impl Parse for Ident {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
if let Some((ident, rest)) = cursor.ident() {
match ident.to_string().as_str() {
"_"
diff --git a/src/synom.rs b/src/synom.rs
index a768c73..347e6f6 100644
--- a/src/synom.rs
+++ b/src/synom.rs
@@ -168,13 +168,13 @@
impl Parse for TokenStream {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| Ok((cursor.token_stream(), Cursor::empty())))
+ input.step(|cursor| Ok((cursor.token_stream(), Cursor::empty())))
}
}
impl Parse for TokenTree {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| match cursor.token_tree() {
+ input.step(|cursor| match cursor.token_tree() {
Some((tt, rest)) => Ok((tt, rest)),
None => Err(cursor.error("expected token tree")),
})
@@ -183,7 +183,7 @@
impl Parse for Group {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
for delim in &[Delimiter::Parenthesis, Delimiter::Brace, Delimiter::Bracket] {
if let Some((inside, span, rest)) = cursor.group(*delim) {
let mut group = Group::new(*delim, inside.token_stream());
@@ -198,7 +198,7 @@
impl Parse for Punct {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| match cursor.punct() {
+ input.step(|cursor| match cursor.punct() {
Some((punct, rest)) => Ok((punct, rest)),
None => Err(cursor.error("expected punctuation token")),
})
@@ -207,7 +207,7 @@
impl Parse for Literal {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| match cursor.literal() {
+ input.step(|cursor| match cursor.literal() {
Some((literal, rest)) => Ok((literal, rest)),
None => Err(cursor.error("expected literal token")),
})
@@ -316,7 +316,7 @@
impl IdentExt for Ident {
fn parse_any(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| match cursor.ident() {
+ input.step(|cursor| match cursor.ident() {
Some((ident, rest)) => Ok((ident, rest)),
None => Err(cursor.error("expected ident")),
})
diff --git a/src/token.rs b/src/token.rs
index fb0c5c0..f7d6ec8 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -430,7 +430,7 @@
#[cfg(feature = "parsing")]
impl Parse for Apostrophe {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
if let Some((punct, rest)) = cursor.punct() {
if punct.as_char() == '\'' && punct.spacing() == Spacing::Joint {
return Ok((Apostrophe(punct.span()), rest));
@@ -451,7 +451,7 @@
#[cfg(feature = "parsing")]
impl Parse for Underscore {
fn parse(input: ParseStream) -> Result<Self> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
if let Some((ident, rest)) = cursor.ident() {
if ident == "_" {
return Ok((Underscore(ident.span()), rest));
@@ -738,7 +738,7 @@
use span::FromSpans;
pub fn keyword(input: ParseStream, token: &str) -> Result<Span> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
if let Some((ident, rest)) = cursor.ident() {
if ident == token {
return Ok((ident.span(), rest));
@@ -749,7 +749,7 @@
}
pub fn punct<S: FromSpans>(input: ParseStream, token: &str) -> Result<S> {
- input.step_cursor(|cursor| {
+ input.step(|cursor| {
let mut cursor = *cursor;
let mut spans = [cursor.span(); 3];
assert!(token.len() <= spans.len());