Skip to content

Commit

Permalink
Fix linting warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiemh committed Sep 23, 2022
1 parent 26de0b5 commit 5fe1fd0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/src/fnc/script/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@ 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();
return Ok(Uuid::from(v).into());
}
// 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);
Expand Down
27 changes: 15 additions & 12 deletions lib/src/sql/value/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down

0 comments on commit 5fe1fd0

Please sign in to comment.