Skip to content

Commit 4493b60

Browse files
committed
fix: code formatting
1 parent b393f7e commit 4493b60

File tree

3 files changed

+60
-17
lines changed

3 files changed

+60
-17
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ impl CompiledProgram {
133133

134134
/// Access the Simplicity target code, without witness data.
135135
pub fn commit(&self) -> Arc<CommitNode<Elements>> {
136-
named::to_commit_node(&self.simplicity).expect("Compiled SimplicityHL program has type 1 -> 1")
136+
named::to_commit_node(&self.simplicity)
137+
.expect("Compiled SimplicityHL program has type 1 -> 1")
137138
}
138139

139140
/// Satisfy the SimplicityHL program with the given `witness_values`.

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ fn run() -> Result<(), String> {
6868
.map(|wit_file| -> Result<simplicityhl::WitnessValues, String> {
6969
let wit_path = std::path::Path::new(wit_file);
7070
let wit_text = std::fs::read_to_string(wit_path).map_err(|e| e.to_string())?;
71-
let witness = serde_json::from_str::<simplicityhl::WitnessValues>(&wit_text).unwrap();
71+
let witness =
72+
serde_json::from_str::<simplicityhl::WitnessValues>(&wit_text).unwrap();
7273
Ok(witness)
7374
})
7475
.transpose()?

src/value.rs

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,10 @@ impl ValueConstructible for Value {
528528
}
529529

530530
fn none(inner: Self::Type) -> Self {
531-
Self { inner: ValueInner::Option(None), ty: ResolvedType::option(inner) }
531+
Self {
532+
inner: ValueInner::Option(None),
533+
ty: ResolvedType::option(inner),
534+
}
532535
}
533536

534537
fn some(inner: Self) -> Self {
@@ -541,15 +544,24 @@ impl ValueConstructible for Value {
541544
fn tuple<I: IntoIterator<Item = Self>>(elements: I) -> Self {
542545
let values: Arc<[Self]> = elements.into_iter().collect();
543546
let ty = ResolvedType::tuple(values.iter().map(Value::ty).map(ResolvedType::clone));
544-
Self { inner: ValueInner::Tuple(values), ty }
547+
Self {
548+
inner: ValueInner::Tuple(values),
549+
ty,
550+
}
545551
}
546552

547553
fn array<I: IntoIterator<Item = Self>>(elements: I, ty: Self::Type) -> Self {
548554
let values: Arc<[Self]> = elements.into_iter().collect();
549555
for value in values.iter() {
550-
assert!(value.is_of_type(&ty), "Element {value} is not of expected type {ty}");
556+
assert!(
557+
value.is_of_type(&ty),
558+
"Element {value} is not of expected type {ty}"
559+
);
560+
}
561+
Self {
562+
ty: ResolvedType::array(ty, values.len()),
563+
inner: ValueInner::Array(values),
551564
}
552-
Self { ty: ResolvedType::array(ty, values.len()), inner: ValueInner::Array(values) }
553565
}
554566

555567
fn list<I: IntoIterator<Item = Self>>(
@@ -563,21 +575,33 @@ impl ValueConstructible for Value {
563575
"There must be fewer list elements than the bound {bound}"
564576
);
565577
for element in elements.iter() {
566-
assert!(element.is_of_type(&ty), "Element {element} is not of expected type {ty}");
578+
assert!(
579+
element.is_of_type(&ty),
580+
"Element {element} is not of expected type {ty}"
581+
);
582+
}
583+
Self {
584+
inner: ValueInner::List(elements, bound),
585+
ty: ResolvedType::list(ty, bound),
567586
}
568-
Self { inner: ValueInner::List(elements, bound), ty: ResolvedType::list(ty, bound) }
569587
}
570588
}
571589

572590
impl From<bool> for Value {
573591
fn from(value: bool) -> Self {
574-
Self { inner: ValueInner::Boolean(value), ty: ResolvedType::boolean() }
592+
Self {
593+
inner: ValueInner::Boolean(value),
594+
ty: ResolvedType::boolean(),
595+
}
575596
}
576597
}
577598

578599
impl From<UIntValue> for Value {
579600
fn from(value: UIntValue) -> Self {
580-
Self { ty: value.get_type().into(), inner: ValueInner::UInt(value) }
601+
Self {
602+
ty: value.get_type().into(),
603+
inner: ValueInner::UInt(value),
604+
}
581605
}
582606
}
583607

@@ -911,7 +935,10 @@ impl ValueConstructible for StructuralValue {
911935
fn array<I: IntoIterator<Item = Self>>(elements: I, ty: Self::Type) -> Self {
912936
let elements: Vec<Self> = elements.into_iter().collect();
913937
for element in &elements {
914-
assert!(element.is_of_type(&ty), "Element {element} is not of expected type {ty}");
938+
assert!(
939+
element.is_of_type(&ty),
940+
"Element {element} is not of expected type {ty}"
941+
);
915942
}
916943
let tree = BTreeSlice::from_slice(&elements);
917944
tree.fold(Self::product).unwrap_or_else(Self::unit)
@@ -928,7 +955,10 @@ impl ValueConstructible for StructuralValue {
928955
"There must be fewer list elements than the bound {bound}"
929956
);
930957
for element in &elements {
931-
assert!(element.is_of_type(&ty), "Element {element} is not of expected type {ty}");
958+
assert!(
959+
element.is_of_type(&ty),
960+
"Element {element} is not of expected type {ty}"
961+
);
932962
}
933963
let partition = Partition::from_slice(&elements, bound);
934964
let process = |block: &[Self], size: usize| -> Self {
@@ -1028,7 +1058,10 @@ impl StructuralValue {
10281058
}
10291059

10301060
fn destruct<'a>(&'a self, ty: &'a ResolvedType) -> Destructor<'a> {
1031-
Destructor::Ok { value: self.0.as_ref(), ty }
1061+
Destructor::Ok {
1062+
value: self.0.as_ref(),
1063+
ty,
1064+
}
10321065
}
10331066
}
10341067

@@ -1060,7 +1093,10 @@ impl StructuralValue {
10601093
/// from the leaf Simplicity values may fail, in which case the entire tree is, again, ill-typed.
10611094
#[derive(Clone, Debug)]
10621095
enum Destructor<'a> {
1063-
Ok { value: ValueRef<'a>, ty: &'a ResolvedType },
1096+
Ok {
1097+
value: ValueRef<'a>,
1098+
ty: &'a ResolvedType,
1099+
},
10641100
WrongType,
10651101
}
10661102

@@ -1211,8 +1247,10 @@ mod tests {
12111247
assert_eq!("(1, 42, 1337)", &triple.to_string());
12121248
let empty_array = Value::array([], ResolvedType::unit());
12131249
assert_eq!("[]", &empty_array.to_string());
1214-
let array =
1215-
Value::array([Value::unit(), Value::unit(), Value::unit()], ResolvedType::unit());
1250+
let array = Value::array(
1251+
[Value::unit(), Value::unit(), Value::unit()],
1252+
ResolvedType::unit(),
1253+
);
12161254
assert_eq!("[(), (), ()]", &array.to_string());
12171255
let list = Value::list([Value::unit()], ResolvedType::unit(), NonZeroPow2Usize::TWO);
12181256
assert_eq!("list![()]", &list.to_string());
@@ -1261,7 +1299,10 @@ mod tests {
12611299
(
12621300
"[1, 2, 3]",
12631301
ResolvedType::array(UIntType::U4.into(), 3),
1264-
Value::array([Value::u4(1), Value::u4(2), Value::u4(3)], UIntType::U4.into()),
1302+
Value::array(
1303+
[Value::u4(1), Value::u4(2), Value::u4(3)],
1304+
UIntType::U4.into(),
1305+
),
12651306
),
12661307
(
12671308
"list![1, 2, 3]",

0 commit comments

Comments
 (0)