Fix linting warnings

This commit is contained in:
Tobie Morgan Hitchcock 2022-09-23 08:41:40 +01:00
parent 26de0b5c46
commit 5fe1fd0227
2 changed files with 19 additions and 16 deletions

View file

@ -38,21 +38,21 @@ impl<'js> FromJs<'js> for Value {
// Extract the value as an object
let v = val.into_object().unwrap();
// Check to see if this object is a duration
if (&v).instance_of::<classes::duration::duration::Duration>() {
if (v).instance_of::<classes::duration::duration::Duration>() {
let v = v.into_instance::<classes::duration::duration::Duration>().unwrap();
let v: &classes::duration::duration::Duration = v.as_ref();
let v = v.value.clone();
return Ok(Duration::from(v).into());
}
// Check to see if this object is a record
if (&v).instance_of::<classes::record::record::Record>() {
if (v).instance_of::<classes::record::record::Record>() {
let v = v.into_instance::<classes::record::record::Record>().unwrap();
let v: &classes::record::record::Record = v.as_ref();
let v = (v.tb.clone(), v.id.clone());
return Ok(Thing::from(v).into());
}
// Check to see if this object is a uuid
if (&v).instance_of::<classes::uuid::uuid::Uuid>() {
if (v).instance_of::<classes::uuid::uuid::Uuid>() {
let v = v.into_instance::<classes::uuid::uuid::Uuid>().unwrap();
let v: &classes::uuid::uuid::Uuid = v.as_ref();
let v = v.value.clone();
@ -60,7 +60,7 @@ impl<'js> FromJs<'js> for Value {
}
// Check to see if this object is a date
let date: js::Object = ctx.globals().get("Date")?;
if (&v).is_instance_of(&date) {
if (v).is_instance_of(&date) {
let f: js::Function = v.get("getTime")?;
let m: i64 = f.call((js::This(v),))?;
let d = Utc.timestamp_millis(m);

View file

@ -41,18 +41,21 @@ impl Value {
let path = path.next();
v.iter_mut().for_each(|v| v.put(path, val.clone()));
}
Part::First => match v.first_mut() {
Some(v) => v.put(path.next(), val),
None => (),
},
Part::Last => match v.last_mut() {
Some(v) => v.put(path.next(), val),
None => (),
},
Part::Index(i) => match v.get_mut(i.to_usize()) {
Some(v) => v.put(path.next(), val),
None => (),
},
Part::First => {
if let Some(v) = v.first_mut() {
v.put(path.next(), val)
}
}
Part::Last => {
if let Some(v) = v.last_mut() {
v.put(path.next(), val)
}
}
Part::Index(i) => {
if let Some(v) = v.get_mut(i.to_usize()) {
v.put(path.next(), val)
}
}
_ => {
v.iter_mut().for_each(|v| v.put(path, val.clone()));
}