mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
node: less unwraps (#6388)
* Update api/node/rust/interpreter/value.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev> --------- Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
This commit is contained in:
parent
68a4e15cff
commit
4b880a7b49
5 changed files with 171 additions and 17 deletions
|
@ -239,7 +239,14 @@ pub fn to_value(env: &Env, unknown: JsUnknown, typ: &Type) -> Result<Value> {
|
|||
let mut vec = vec![];
|
||||
|
||||
for i in 0..array.len() {
|
||||
vec.push(to_value(env, array.get(i)?.unwrap(), a)?);
|
||||
vec.push(to_value(
|
||||
env,
|
||||
array.get(i)?.ok_or(napi::Error::from_reason(format!(
|
||||
"Cannot access array element at index {}",
|
||||
i
|
||||
)))?,
|
||||
a,
|
||||
)?);
|
||||
}
|
||||
Ok(Value::Model(ModelRc::new(SharedVectorModel::from(SharedVector::from_slice(
|
||||
&vec,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue