Fix panic on invalid entity
This commit is contained in:
parent
dc7821806c
commit
ad918f8597
1 changed files with 6 additions and 1 deletions
|
@ -245,7 +245,12 @@ impl Entity {
|
|||
let obj = ents.as_object_mut().ok_or(EntityError::ExpectedObject)?;
|
||||
match obj.len() {
|
||||
0 => return Err(EntityError::NoEntities),
|
||||
1 => obj.iter_mut().next().unwrap().1.take(),
|
||||
1 => obj
|
||||
.iter_mut()
|
||||
.next()
|
||||
.ok_or(EntityError::ExpectedObject)?
|
||||
.1
|
||||
.take(),
|
||||
_ => return Err(EntityError::MultipleEntities),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue