pub fn new<T: Display>(span: Span, message: T) -> Self {
        Error {
            messages: vec![ErrorMessage {
                start_span: ThreadBound::new(span),
                end_span: ThreadBound::new(span),
                message: message.to_string(),
            }],
        }
    }
/// Usually the [`ParseStream::error`] method will be used instead, which
/// automatically uses the correct span from the current position of the
/// parse stream.
///
/// Use `Error::new` when the error needs to be triggered on some span other
/// than where the parse stream is currently positioned.
///
/// [`ParseStream::error`]: crate::parse::ParseBuffer::error
///
/// # Example
///
/// ```
/// use syn::{Error, Ident, LitStr, Result, Token};
/// use syn::parse::ParseStream;
///
/// // Parses input that looks like `name = "string"` where the key must be
/// // the identifier `name` and the value may be any string literal.
/// // Returns the string literal.
/// fn parse_name(input: ParseStream) -> Result<LitStr> {
///     let name_token: Ident = input.parse()?;
///     if name_token != "name" {
///         // Trigger an error not on the current position of the stream,
///         // but on the position of the unexpected identifier.
///         return Err(Error::new(name_token.span(), "expected `name`"));
///     }
///     input.parse::<Token![=]>()?;
///     let s: LitStr = input.parse()?;
///     Ok(s)
/// }
/// ```
Usually the [`ParseStream::error`] method will be used instead, which
automatically uses the correct span from the current position of the
parse stream.

Use `Error::new` when the error needs to be triggered on some span other
than where the parse stream is currently positioned.


Usually the [ ` ParseStream :: error ` ] method will be used instead which automatically uses the correct span from the current position of the parse stream . Use ` Error :: new ` when the error needs to be triggered on some span other than where the parse stream is currently positioned .
pub fn new<T: Display>(span: Span, message: T) -> Self {
        Error {
            messages: vec![ErrorMessage {
                start_span: ThreadBound::new(span),
                end_span: ThreadBound::new(span),
                message: message.to_string(),
            }],
        }
    }
pub fn new < T : Display > ( span : Span , message : T ) -> Self { Error { messages : vec ! [ ErrorMessage { start_span ThreadBound new ( span ) end_span ThreadBound new ( span ) message message to_string ( ) } ] , } }
Usually the [`ParseStream::error`] method will be used instead, which
automatically uses the correct span from the current position of the
parse stream.
Usually the [ ` ParseStream :: error ` ] method will be used instead which automatically uses the correct span from the current position of the parse stream .
span
Span
message
T
span
Span
message
T
example
```
use syn::{Error, Ident, LitStr, Result, Token};
use syn::parse::ParseStream.

Parses input that looks like `name = "string"` where the key must be
the identifier `name` and the value may be any string literal.
Returns the string literal.
fn parse_name(input: ParseStream) -> Result {
let name_token: Ident = input.parse()?;
if name_token != "name" {
Trigger an error not on the current position of the stream,
but on the position of the unexpected identifier.
return Err(Error::new(name_token.span(), "expected `name`"));
}
input.parse::()?;
let s: LitStr = input.parse()?;
Ok(s)
}
```
` ` ` use syn :: { Error Ident LitStr Result Token } ; use syn :: parse :: ParseStream . Parses input that looks like ` name = " string " ` where the key must be the identifier ` name ` and the value may be any string literal . Returns the string literal . fn parse_name ( input : ParseStream ) - > Result { let name_token : Ident = input . parse () ? ; if name_token ! = " name " { Trigger an error not on the current position of the stream but on the position of the unexpected identifier . return Err ( Error :: new ( name_token . span () " expected ` name ` " )) ; } input . parse :: () ? ; let s : LitStr = input . parse () ? ; Ok ( s ) } ` ` `