Skip to content

Commit bbd6bc0

Browse files
committed
fix: apply cargo fmt to meet CI requirements
1 parent 3d462a2 commit bbd6bc0

36 files changed

+4489
-1576
lines changed

crates/ovsm/src/tools/stdlib/advanced_math.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -993,11 +993,7 @@ impl Tool for AshTool {
993993
let n = args[0].as_int()?;
994994
let count = args[1].as_int()?;
995995

996-
let result = if count >= 0 {
997-
n << count
998-
} else {
999-
n >> -count
1000-
};
996+
let result = if count >= 0 { n << count } else { n >> -count };
1001997

1002998
Ok(Value::Int(result))
1003999
}
@@ -1062,11 +1058,23 @@ impl Tool for SignumTool {
10621058

10631059
match &args[0] {
10641060
Value::Int(n) => {
1065-
let sign = if *n < 0 { -1 } else if *n > 0 { 1 } else { 0 };
1061+
let sign = if *n < 0 {
1062+
-1
1063+
} else if *n > 0 {
1064+
1
1065+
} else {
1066+
0
1067+
};
10661068
Ok(Value::Int(sign))
10671069
}
10681070
Value::Float(f) => {
1069-
let sign = if *f < 0.0 { -1.0 } else if *f > 0.0 { 1.0 } else { 0.0 };
1071+
let sign = if *f < 0.0 {
1072+
-1.0
1073+
} else if *f > 0.0 {
1074+
1.0
1075+
} else {
1076+
0.0
1077+
};
10701078
Ok(Value::Float(sign))
10711079
}
10721080
_ => Err(Error::TypeError {

crates/ovsm/src/tools/stdlib/arrays.rs

Lines changed: 91 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ impl Tool for ArefTool {
155155
let array = args[0].as_array()?;
156156
let index = args[1].as_int()? as usize;
157157

158-
array.get(index).cloned().ok_or_else(|| Error::IndexOutOfBounds {
159-
index,
160-
length: array.len(),
161-
})
158+
array
159+
.get(index)
160+
.cloned()
161+
.ok_or_else(|| Error::IndexOutOfBounds {
162+
index,
163+
length: array.len(),
164+
})
162165
}
163166
}
164167

@@ -545,9 +548,12 @@ impl Tool for CaadrTool {
545548
}
546549

547550
let second = list[1].as_array()?;
548-
second.first().cloned().ok_or_else(|| Error::EmptyCollection {
549-
operation: "CAADR".to_string(),
550-
})
551+
second
552+
.first()
553+
.cloned()
554+
.ok_or_else(|| Error::EmptyCollection {
555+
operation: "CAADR".to_string(),
556+
})
551557
}
552558
}
553559

@@ -670,18 +676,30 @@ impl Tool for CaaaarTool {
670676
});
671677
}
672678

673-
let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
674-
operation: "CAAAAR".to_string(),
675-
})?;
676-
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
677-
operation: "CAAAAR".to_string(),
678-
})?;
679-
let l3 = l2.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
680-
operation: "CAAAAR".to_string(),
681-
})?;
682-
let l4 = l3.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
683-
operation: "CAAAAR".to_string(),
684-
})?;
679+
let l1 = args[0]
680+
.as_array()?
681+
.first()
682+
.ok_or_else(|| Error::EmptyCollection {
683+
operation: "CAAAAR".to_string(),
684+
})?;
685+
let l2 = l1
686+
.as_array()?
687+
.first()
688+
.ok_or_else(|| Error::EmptyCollection {
689+
operation: "CAAAAR".to_string(),
690+
})?;
691+
let l3 = l2
692+
.as_array()?
693+
.first()
694+
.ok_or_else(|| Error::EmptyCollection {
695+
operation: "CAAAAR".to_string(),
696+
})?;
697+
let l4 = l3
698+
.as_array()?
699+
.first()
700+
.ok_or_else(|| Error::EmptyCollection {
701+
operation: "CAAAAR".to_string(),
702+
})?;
685703

686704
Ok(l4.clone())
687705
}
@@ -707,15 +725,24 @@ impl Tool for CdaaarTool {
707725
});
708726
}
709727

710-
let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
711-
operation: "CDAAAR".to_string(),
712-
})?;
713-
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
714-
operation: "CDAAAR".to_string(),
715-
})?;
716-
let l3 = l2.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
717-
operation: "CDAAAR".to_string(),
718-
})?;
728+
let l1 = args[0]
729+
.as_array()?
730+
.first()
731+
.ok_or_else(|| Error::EmptyCollection {
732+
operation: "CDAAAR".to_string(),
733+
})?;
734+
let l2 = l1
735+
.as_array()?
736+
.first()
737+
.ok_or_else(|| Error::EmptyCollection {
738+
operation: "CDAAAR".to_string(),
739+
})?;
740+
let l3 = l2
741+
.as_array()?
742+
.first()
743+
.ok_or_else(|| Error::EmptyCollection {
744+
operation: "CDAAAR".to_string(),
745+
})?;
719746
let l4 = l3.as_array()?;
720747

721748
if l4.is_empty() {
@@ -746,12 +773,18 @@ impl Tool for CadaarTool {
746773
});
747774
}
748775

749-
let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
750-
operation: "CADAAR".to_string(),
751-
})?;
752-
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
753-
operation: "CADAAR".to_string(),
754-
})?;
776+
let l1 = args[0]
777+
.as_array()?
778+
.first()
779+
.ok_or_else(|| Error::EmptyCollection {
780+
operation: "CADAAR".to_string(),
781+
})?;
782+
let l2 = l1
783+
.as_array()?
784+
.first()
785+
.ok_or_else(|| Error::EmptyCollection {
786+
operation: "CADAAR".to_string(),
787+
})?;
755788
let l3 = l2.as_array()?;
756789

757790
if l3.len() < 2 {
@@ -785,12 +818,18 @@ impl Tool for CddaarTool {
785818
});
786819
}
787820

788-
let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
789-
operation: "CDDAAR".to_string(),
790-
})?;
791-
let l2 = l1.as_array()?.first().ok_or_else(|| Error::EmptyCollection {
792-
operation: "CDDAAR".to_string(),
793-
})?;
821+
let l1 = args[0]
822+
.as_array()?
823+
.first()
824+
.ok_or_else(|| Error::EmptyCollection {
825+
operation: "CDDAAR".to_string(),
826+
})?;
827+
let l2 = l1
828+
.as_array()?
829+
.first()
830+
.ok_or_else(|| Error::EmptyCollection {
831+
operation: "CDDAAR".to_string(),
832+
})?;
794833
let l3 = l2.as_array()?;
795834

796835
if l3.len() < 2 {
@@ -821,9 +860,12 @@ impl Tool for CaadarTool {
821860
});
822861
}
823862

824-
let l1 = args[0].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
825-
operation: "CAADAR".to_string(),
826-
})?;
863+
let l1 = args[0]
864+
.as_array()?
865+
.first()
866+
.ok_or_else(|| Error::EmptyCollection {
867+
operation: "CAADAR".to_string(),
868+
})?;
827869
let l2 = l1.as_array()?;
828870

829871
if l2.len() < 2 {
@@ -833,9 +875,12 @@ impl Tool for CaadarTool {
833875
});
834876
}
835877

836-
let l3 = l2[1].as_array()?.first().ok_or_else(|| Error::EmptyCollection {
837-
operation: "CAADAR".to_string(),
838-
})?;
878+
let l3 = l2[1]
879+
.as_array()?
880+
.first()
881+
.ok_or_else(|| Error::EmptyCollection {
882+
operation: "CAADAR".to_string(),
883+
})?;
839884

840885
Ok(l3.clone())
841886
}

0 commit comments

Comments
 (0)