fn add_assign(&mut self, assign: &syn::ExprAssign) -> syn::Result<()> {
        let syn::ExprAssign { left, right, .. } = assign;
        let key = match &**left {
            syn::Expr::Path(exp) if exp.path.segments.len() == 1 => {
                exp.path.segments.first().unwrap().ident.to_string()
            }
            _ => bail_spanned!(assign.span() => "failed to parse arguments"),
        };

        macro_rules! expected {
            ($expected: literal) => {
                expected!($expected, right.span())
            };
            ($expected: literal, $span: expr) => {
                bail_spanned!($span => concat!("expected ", $expected));
            };
        }

        match key.as_str() {
            "freelist" => {
                // We allow arbitrary expressions here so you can e.g. use `8*64`
                self.freelist = Some(syn::Expr::clone(right));
            }
            "name" => match &**right {
                syn::Expr::Lit(syn::ExprLit {
                    lit: syn::Lit::Str(lit),
                    ..
                }) => {
                    self.name = Some(lit.parse().map_err(|_| {
                        err_spanned!(
                                lit.span() => "expected a single identifier in double-quotes")
                    })?);
                }
                syn::Expr::Path(exp) if exp.path.segments.len() == 1 => {
                    bail_spanned!(
                        exp.span() => format!(
                            "since PyO3 0.13 a pyclass name should be in double-quotes, \
                            e.g. \"{}\"",
                            exp.path.get_ident().expect("path has 1 segment")
                        )
                    );
                }
                _ => expected!("type name (e.g. \"Name\")"),
            },
            "extends" => match &**right {
                syn::Expr::Path(exp) => {
                    self.base = syn::TypePath {
                        path: exp.path.clone(),
                        qself: None,
                    };
                    self.has_extends = true;
                }
                _ => expected!("type path (e.g., my_mod::BaseClass)"),
            },
            "module" => match &**right {
                syn::Expr::Lit(syn::ExprLit {
                    lit: syn::Lit::Str(lit),
                    ..
                }) => {
                    self.module = Some(lit.clone());
                }
                _ => expected!(r#"string literal (e.g., "my_mod")"#),
            },
            _ => expected!("one of freelist/name/extends/module", left.span()),
        };

        Ok(())
    }
/// Match a key/value flag
Match a key/value flag
Match a key / value flag
fn add_assign(&mut self, assign: &syn::ExprAssign) -> syn::Result<()> {
        let syn::ExprAssign { left, right, .. } = assign;
        let key = match &**left {
            syn::Expr::Path(exp) if exp.path.segments.len() == 1 => {
                exp.path.segments.first().unwrap().ident.to_string()
            }
            _ => bail_spanned!(assign.span() => "failed to parse arguments"),
        };
        macro_rules! expected {
            ($expected: literal) => {
                expected!($expected, right.span())
            };
            ($expected: literal, $span: expr) => {
                bail_spanned!($span => concat!("expected ", $expected));
            };
        }
        match key.as_str() {
            "freelist" => {
                // We allow arbitrary expressions here so you can e.g. use `8*64`
                self.freelist = Some(syn::Expr::clone(right));
            }
            "name" => match &**right {
                syn::Expr::Lit(syn::ExprLit {
                    lit: syn::Lit::Str(lit),
                    ..
                }) => {
                    self.name = Some(lit.parse().map_err(|_| {
                        err_spanned!(
                                lit.span() => "expected a single identifier in double-quotes")
                    })?);
                }
                syn::Expr::Path(exp) if exp.path.segments.len() == 1 => {
                    bail_spanned!(
                        exp.span() => format!(
                            "since PyO3 0.13 a pyclass name should be in double-quotes, \
                            e.g. \"{}\"",
                            exp.path.get_ident().expect("path has 1 segment")
                        )
                    );
                }
                _ => expected!("type name (e.g. \"Name\")"),
            },
            "extends" => match &**right {
                syn::Expr::Path(exp) => {
                    self.base = syn::TypePath {
                        path: exp.path.clone(),
                        qself: None,
                    };
                    self.has_extends = true;
                }
                _ => expected!("type path (e.g., my_mod::BaseClass)"),
            },
            "module" => match &**right {
                syn::Expr::Lit(syn::ExprLit {
                    lit: syn::Lit::Str(lit),
                    ..
                }) => {
                    self.module = Some(lit.clone());
                }
                _ => expected!(r#"string literal (e.g., "my_mod")"#),
            },
            _ => expected!("one of freelist/name/extends/module", left.span()),
        };
        Ok(())
    }
fn add_assign ( & mut self , assign : & syn :: ExprAssign ) -> syn :: Result < ( ) > { let syn :: ExprAssign { left , right , .. } = assign ; let key = match & * * left { syn :: Expr :: Path ( exp ) if exp . path . segments . len ( ) == 1 => { exp . path . segments . first ( ) . unwrap ( ) . ident . to_string ( ) } _ => bail_spanned ! ( assign span ( ) " " ) , } ; macro_rules! expected { ( $expected : literal ) => { expected ( $expected right span ( ) ) } ; ( $expected : literal $span : expr ) => { bail_spanned ( $span concat ( " " $expected ) ) } ; } match key . as_str ( ) { " " => { // We allow arbitrary expressions here so you can e.g. use `8*64` self . freelist = Some ( syn :: Expr :: clone ( right ) ) ; } " " => match & * * right { syn :: Expr :: Lit ( syn :: ExprLit { lit : syn :: Lit :: Str ( lit ) , .. } ) => { self . name = Some ( lit . parse ( ) . map_err ( | _ | { err_spanned ! ( lit span ( ) " " ) } ) ? ) ; } syn :: Expr :: Path ( exp ) if exp . path . segments . len ( ) == 1 => { bail_spanned ! ( exp span ( ) format ( " \
 \" \" " exp path get_ident ( ) expect ( " " ) ) ) ; } _ => expected ! ( " \" \" " ) , } , " " => match & * * right { syn :: Expr :: Path ( exp ) => { self . base = syn :: TypePath { path : exp . path . clone ( ) , qself : None , } ; self . has_extends = true ; } _ => expected ! ( " " ) , } , " " => match & * * right { syn :: Expr :: Lit ( syn :: ExprLit { lit : syn :: Lit :: Str ( lit ) , .. } ) => { self . module = Some ( lit . clone ( ) ) ; } _ => expected ! ( r#"string literal (e.g., "my_mod")"# ) , } , _ => expected ! ( " " left span ( ) ) , } ; Ok ( ( ) ) }
Match a key/value flag
Match a key / value flag
&mut self
assign
&syn::ExprAssign
&mut self
assign
&syn::ExprAssign