pub fn new(attribute: &'a ast::Attribute) -> Result<Arguments<'a>, Diagnostics> {
        let arguments = &attribute.arguments;
        let span = attribute.span;
        let mut remaining_arguments = HashMap::with_capacity(arguments.len()); // validation will succeed more often than not
        let mut errors = Diagnostics::new();
        let mut unnamed_arguments = Vec::new();

        for arg in arguments {
            if let Some(existing_argument) = remaining_arguments.insert(arg.name.name.as_str(), arg) {
                if arg.is_unnamed() {
                    if unnamed_arguments.is_empty() {
                        unnamed_arguments.push(existing_argument.value.render_to_string())
                    }

                    unnamed_arguments.push(arg.value.render_to_string())
                } else {
                    errors.push_error(DatamodelError::new_duplicate_argument_error(&arg.name.name, arg.span));
                }
            }
        }

        if !unnamed_arguments.is_empty() {
            errors.push_error(DatamodelError::new_attribute_validation_error(
                &format!("You provided multiple unnamed arguments. This is not possible. Did you forget the brackets? Did you mean `[{}]`?", unnamed_arguments.join(", ")),
                attribute.name.name.as_str(),
                span
            ))
        }

        errors.to_result()?;

        Ok(Arguments {
            args: remaining_arguments,
            span,
        })
    }
/// Creates a new instance for an attribute, checking for duplicate arguments in the process.
Creates a new instance for an attribute, checking for duplicate arguments in the process.
Creates a new instance for an attribute checking for duplicate arguments in the process .
pub fn new(attribute: &'a ast::Attribute) -> Result<Arguments<'a>, Diagnostics> {
        let arguments = &attribute.arguments;
        let span = attribute.span;
        let mut remaining_arguments = HashMap::with_capacity(arguments.len()); // validation will succeed more often than not
        let mut errors = Diagnostics::new();
        let mut unnamed_arguments = Vec::new();
        for arg in arguments {
            if let Some(existing_argument) = remaining_arguments.insert(arg.name.name.as_str(), arg) {
                if arg.is_unnamed() {
                    if unnamed_arguments.is_empty() {
                        unnamed_arguments.push(existing_argument.value.render_to_string())
                    }
                    unnamed_arguments.push(arg.value.render_to_string())
                } else {
                    errors.push_error(DatamodelError::new_duplicate_argument_error(&arg.name.name, arg.span));
                }
            }
        }
        if !unnamed_arguments.is_empty() {
            errors.push_error(DatamodelError::new_attribute_validation_error(
                &format!("You provided multiple unnamed arguments. This is not possible. Did you forget the brackets? Did you mean `[{}]`?", unnamed_arguments.join(", ")),
                attribute.name.name.as_str(),
                span
            ))
        }
        errors.to_result()?;
        Ok(Arguments {
            args: remaining_arguments,
            span,
        })
    }
pub fn new ( attribute : & ' a ast :: Attribute ) -> Result < Arguments < ' a > , Diagnostics > { let arguments = & attribute . arguments ; let span = attribute . span ; let mut remaining_arguments = HashMap :: with_capacity ( arguments . len ( ) ) ; // validation will succeed more often than not let mut errors = Diagnostics :: new ( ) ; let mut unnamed_arguments = Vec :: new ( ) ; for arg in arguments { if let Some ( existing_argument ) = remaining_arguments . insert ( arg . name . name . as_str ( ) , arg ) { if arg . is_unnamed ( ) { if unnamed_arguments . is_empty ( ) { unnamed_arguments . push ( existing_argument . value . render_to_string ( ) ) } unnamed_arguments . push ( arg . value . render_to_string ( ) ) } else { errors . push_error ( DatamodelError :: new_duplicate_argument_error ( & arg . name . name , arg . span ) ) ; } } } if ! unnamed_arguments . is_empty ( ) { errors . push_error ( DatamodelError :: new_attribute_validation_error ( & format ! ( " " unnamed_arguments join ( " " ) ) , attribute . name . name . as_str ( ) , span ) ) } errors . to_result ( ) ? ; Ok ( Arguments { args : remaining_arguments , span , } ) }
Creates a new instance for an attribute, checking for duplicate arguments in the process.
Creates a new instance for an attribute checking for duplicate arguments in the process .
attribute
&'a ast::Attribute