优化代码,避免使用clone导致额外的内存占用
This commit is contained in:
parent
79fabc6bcc
commit
7b84948624
@ -24,8 +24,8 @@ pub fn validate_params(params: &impl Validate, local: &str) -> ResResult<ResData
|
||||
},
|
||||
validator::ValidationErrorsKind::Field(err) => {
|
||||
err.iter().for_each(|e| {
|
||||
let msg = e.message.clone().unwrap_or_default();
|
||||
errors.push(message!(local, MessageId::from_str(msg.trim()).unwrap()))
|
||||
let msg = e.message.as_ref().unwrap();
|
||||
errors.push(message!(local, MessageId::from_str(msg).unwrap()))
|
||||
});
|
||||
},
|
||||
};
|
||||
@ -38,8 +38,8 @@ pub fn validate_params(params: &impl Validate, local: &str) -> ResResult<ResData
|
||||
fn pack_error_msg(errors: & mut Vec<&str>, raw_errors: &Box<ValidationErrors>, local: &str) {
|
||||
for (_field, errs) in raw_errors.field_errors() {
|
||||
for e in errs {
|
||||
let msg = e.message.clone().unwrap_or_default();
|
||||
errors.push(message!(local, MessageId::from_str(msg.trim()).unwrap()));
|
||||
let msg = e.message.as_ref().unwrap();
|
||||
errors.push(message!(local, MessageId::from_str(msg).unwrap()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user