Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Murzin <diralik@yandex.ru>
  • Loading branch information
dima74 committed Sep 25, 2024
1 parent 170e654 commit 7240b99
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/iroha_data_model/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod model {

impl<A: Instruction> FromIterator<A> for Executable {
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self {
Self::Instructions(iter.into_iter().map(Into::into).collect::<Vec<_>>().into())
Self::Instructions(iter.into_iter().map(Into::into).collect())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_data_model/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn visit_transaction<V: Visit + ?Sized>(
match transaction.instructions() {
Executable::Wasm(wasm) => visitor.visit_wasm(authority, wasm),
Executable::Instructions(instructions) => {
for isi in instructions.as_ref() {
for isi in instructions {
visitor.visit_instruction(authority, isi);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_executor/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn visit_transaction<V: Validate + Visit + ?Sized>(
match transaction.instructions() {
Executable::Wasm(wasm) => executor.visit_wasm(authority, wasm),
Executable::Instructions(instructions) => {
for isi in instructions.as_ref() {
for isi in instructions {
if executor.verdict().is_ok() {
executor.visit_instruction(authority, isi);
}
Expand Down
17 changes: 17 additions & 0 deletions crates/iroha_primitives/src/const_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ impl<T: IntoSchema> IntoSchema for ConstVec<T> {
}
}

impl<'a, T> IntoIterator for &'a ConstVec<T> {
type Item = &'a T;

type IntoIter = <&'a [T] as IntoIterator>::IntoIter;

fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

impl<T> IntoIterator for ConstVec<T> {
type Item = T;

Expand All @@ -102,6 +112,13 @@ impl<T> IntoIterator for ConstVec<T> {
}
}

impl<T> FromIterator<T> for ConstVec<T> {
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
let vec: Vec<T> = iter.into_iter().collect();
Self::new(vec)
}
}

/// Trait to extend `[T]` with a method to convert it to `ConstVec<T>` by analogy with `[T]::to_vec()`.
pub trait ToConstVec {
/// The type of the items in the slice.
Expand Down

0 comments on commit 7240b99

Please # to comment.