pub(crate) fn try_parse<T>(&mut self) -> Result<Option<(Span, T)>, ParseError>
    where
        T: Attribute + Parse,
    {
        let mut matched = None;

        for index in self.unused.iter().copied() {
            let a = match self.attributes.get(index) {
                Some(a) => a,
                None => continue,
            };

            let ident = match a.path.try_as_ident() {
                Some(ident) => ident,
                None => continue,
            };

            let ident = ident.resolve(&self.storage, &self.source)?;

            if ident != T::PATH {
                continue;
            }

            let span = a.span();

            if matched.is_some() {
                return Err(ParseError::new(
                    span,
                    ParseErrorKind::MultipleMatchingAttributes { name: T::PATH },
                ));
            }

            let mut parser = Parser::from_token_stream(&a.input);
            matched = Some((index, span, parser.parse::<T>()?));
            parser.eof()?;
        }

        if let Some((index, span, matched)) = matched {
            self.unused.remove(&index);
            Ok(Some((span, matched)))
        } else {
            Ok(None)
        }
    }
/// Try to parse the attribute with the given type.
///
/// Returns the parsed element and the span it was parsed from if
/// successful.
Try to parse the attribute with the given type.
Returns the parsed element and the span it was parsed from if
successful.
Try to parse the attribute with the given type . Returns the parsed element and the span it was parsed from if successful .
pub(crate) fn try_parse<T>(&mut self) -> Result<Option<(Span, T)>, ParseError>
    where
        T: Attribute + Parse,
    {
        let mut matched = None;
        for index in self.unused.iter().copied() {
            let a = match self.attributes.get(index) {
                Some(a) => a,
                None => continue,
            };
            let ident = match a.path.try_as_ident() {
                Some(ident) => ident,
                None => continue,
            };
            let ident = ident.resolve(&self.storage, &self.source)?;
            if ident != T::PATH {
                continue;
            }
            let span = a.span();
            if matched.is_some() {
                return Err(ParseError::new(
                    span,
                    ParseErrorKind::MultipleMatchingAttributes { name: T::PATH },
                ));
            }
            let mut parser = Parser::from_token_stream(&a.input);
            matched = Some((index, span, parser.parse::<T>()?));
            parser.eof()?;
        }
        if let Some((index, span, matched)) = matched {
            self.unused.remove(&index);
            Ok(Some((span, matched)))
        } else {
            Ok(None)
        }
    }
pub ( crate ) fn try_parse < T > ( & mut self ) -> Result < Option < ( Span , T ) > , ParseError > where T : Attribute + Parse , { let mut matched = None ; for index in self . unused . iter ( ) . copied ( ) { let a = match self . attributes . get ( index ) { Some ( a ) => a , None => continue , } ; let ident = match a . path . try_as_ident ( ) { Some ( ident ) => ident , None => continue , } ; let ident = ident . resolve ( & self . storage , & self . source ) ? ; if ident != T :: PATH { continue ; } let span = a . span ( ) ; if matched . is_some ( ) { return Err ( ParseError :: new ( span , ParseErrorKind :: MultipleMatchingAttributes { name : T :: PATH } , ) ) ; } let mut parser = Parser :: from_token_stream ( & a . input ) ; matched = Some ( ( index , span , parser . parse :: < T > ( ) ? ) ) ; parser . eof ( ) ? ; } if let Some ( ( index , span , matched ) ) = matched { self . unused . remove ( & index ) ; Ok ( Some ( ( span , matched ) ) ) } else { Ok ( None ) } }
Try to parse the attribute with the given type.
Try to parse the attribute with the given type .
&mut self
&mut self