chore: change impl Into<T> for U to impl From<U> for T (#5948)

* chore: Change Into trait impl for KzgProof to From trait impl

* chore: change `impl Into <T> for U` to `impl From<U> for T`

* chore: remove `from-over-into` clippy lint exception
This commit is contained in:
kevaundray
2024-06-19 06:02:26 +01:00
committed by GitHub
parent 9f8aa963b1
commit a87f19d801
20 changed files with 120 additions and 121 deletions

View File

@@ -229,7 +229,6 @@ lint:
-D clippy::manual_let_else \ -D clippy::manual_let_else \
-D warnings \ -D warnings \
-A clippy::derive_partial_eq_without_eq \ -A clippy::derive_partial_eq_without_eq \
-A clippy::from-over-into \
-A clippy::upper-case-acronyms \ -A clippy::upper-case-acronyms \
-A clippy::vec-init-then-push \ -A clippy::vec-init-then-push \
-A clippy::question-mark \ -A clippy::question-mark \

View File

@@ -389,35 +389,35 @@ pub struct PersistedForkChoiceStore {
pub equivocating_indices: BTreeSet<u64>, pub equivocating_indices: BTreeSet<u64>,
} }
impl Into<PersistedForkChoiceStore> for PersistedForkChoiceStoreV11 { impl From<PersistedForkChoiceStoreV11> for PersistedForkChoiceStore {
fn into(self) -> PersistedForkChoiceStore { fn from(from: PersistedForkChoiceStoreV11) -> PersistedForkChoiceStore {
PersistedForkChoiceStore { PersistedForkChoiceStore {
balances_cache: self.balances_cache, balances_cache: from.balances_cache,
time: self.time, time: from.time,
finalized_checkpoint: self.finalized_checkpoint, finalized_checkpoint: from.finalized_checkpoint,
justified_checkpoint: self.justified_checkpoint, justified_checkpoint: from.justified_checkpoint,
justified_balances: self.justified_balances, justified_balances: from.justified_balances,
unrealized_justified_checkpoint: self.unrealized_justified_checkpoint, unrealized_justified_checkpoint: from.unrealized_justified_checkpoint,
unrealized_finalized_checkpoint: self.unrealized_finalized_checkpoint, unrealized_finalized_checkpoint: from.unrealized_finalized_checkpoint,
proposer_boost_root: self.proposer_boost_root, proposer_boost_root: from.proposer_boost_root,
equivocating_indices: self.equivocating_indices, equivocating_indices: from.equivocating_indices,
} }
} }
} }
impl Into<PersistedForkChoiceStoreV11> for PersistedForkChoiceStore { impl From<PersistedForkChoiceStore> for PersistedForkChoiceStoreV11 {
fn into(self) -> PersistedForkChoiceStoreV11 { fn from(from: PersistedForkChoiceStore) -> PersistedForkChoiceStoreV11 {
PersistedForkChoiceStoreV11 { PersistedForkChoiceStoreV11 {
balances_cache: self.balances_cache, balances_cache: from.balances_cache,
time: self.time, time: from.time,
finalized_checkpoint: self.finalized_checkpoint, finalized_checkpoint: from.finalized_checkpoint,
justified_checkpoint: self.justified_checkpoint, justified_checkpoint: from.justified_checkpoint,
justified_balances: self.justified_balances, justified_balances: from.justified_balances,
best_justified_checkpoint: JUNK_BEST_JUSTIFIED_CHECKPOINT, best_justified_checkpoint: JUNK_BEST_JUSTIFIED_CHECKPOINT,
unrealized_justified_checkpoint: self.unrealized_justified_checkpoint, unrealized_justified_checkpoint: from.unrealized_justified_checkpoint,
unrealized_finalized_checkpoint: self.unrealized_finalized_checkpoint, unrealized_finalized_checkpoint: from.unrealized_finalized_checkpoint,
proposer_boost_root: self.proposer_boost_root, proposer_boost_root: from.proposer_boost_root,
equivocating_indices: self.equivocating_indices, equivocating_indices: from.equivocating_indices,
} }
} }
} }

View File

@@ -20,20 +20,20 @@ pub struct PersistedForkChoice {
pub fork_choice_store: PersistedForkChoiceStoreV17, pub fork_choice_store: PersistedForkChoiceStoreV17,
} }
impl Into<PersistedForkChoice> for PersistedForkChoiceV11 { impl From<PersistedForkChoiceV11> for PersistedForkChoice {
fn into(self) -> PersistedForkChoice { fn from(from: PersistedForkChoiceV11) -> PersistedForkChoice {
PersistedForkChoice { PersistedForkChoice {
fork_choice: self.fork_choice, fork_choice: from.fork_choice,
fork_choice_store: self.fork_choice_store.into(), fork_choice_store: from.fork_choice_store.into(),
} }
} }
} }
impl Into<PersistedForkChoiceV11> for PersistedForkChoice { impl From<PersistedForkChoice> for PersistedForkChoiceV11 {
fn into(self) -> PersistedForkChoiceV11 { fn from(from: PersistedForkChoice) -> PersistedForkChoiceV11 {
PersistedForkChoiceV11 { PersistedForkChoiceV11 {
fork_choice: self.fork_choice, fork_choice: from.fork_choice,
fork_choice_store: self.fork_choice_store.into(), fork_choice_store: from.fork_choice_store.into(),
} }
} }
} }

View File

@@ -257,9 +257,9 @@ pub mod deposit_methods {
Latest, Latest,
} }
impl Into<u64> for Eth1Id { impl From<Eth1Id> for u64 {
fn into(self) -> u64 { fn from(from: Eth1Id) -> u64 {
match self { match from {
Eth1Id::Mainnet => 1, Eth1Id::Mainnet => 1,
Eth1Id::Custom(id) => id, Eth1Id::Custom(id) => id,
} }

View File

@@ -1700,11 +1700,11 @@ impl<E: EthSpec> ForkVersionDeserialize for FullBlockContents<E> {
} }
} }
impl<E: EthSpec> Into<BeaconBlock<E>> for FullBlockContents<E> { impl<E: EthSpec> From<FullBlockContents<E>> for BeaconBlock<E> {
fn into(self) -> BeaconBlock<E> { fn from(from: FullBlockContents<E>) -> BeaconBlock<E> {
match self { match from {
Self::BlockContents(block_and_sidecars) => block_and_sidecars.block, FullBlockContents::<E>::BlockContents(block_and_sidecars) => block_and_sidecars.block,
Self::Block(block) => block, FullBlockContents::<E>::Block(block) => block,
} }
} }
} }

View File

@@ -145,24 +145,24 @@ impl TryInto<ProtoNode> for ProtoNodeV16 {
} }
} }
impl Into<ProtoNodeV16> for ProtoNode { impl From<ProtoNode> for ProtoNodeV16 {
fn into(self) -> ProtoNodeV16 { fn from(from: ProtoNode) -> ProtoNodeV16 {
ProtoNodeV16 { ProtoNodeV16 {
slot: self.slot, slot: from.slot,
state_root: self.state_root, state_root: from.state_root,
target_root: self.target_root, target_root: from.target_root,
current_epoch_shuffling_id: self.current_epoch_shuffling_id, current_epoch_shuffling_id: from.current_epoch_shuffling_id,
next_epoch_shuffling_id: self.next_epoch_shuffling_id, next_epoch_shuffling_id: from.next_epoch_shuffling_id,
root: self.root, root: from.root,
parent: self.parent, parent: from.parent,
justified_checkpoint: Some(self.justified_checkpoint), justified_checkpoint: Some(from.justified_checkpoint),
finalized_checkpoint: Some(self.finalized_checkpoint), finalized_checkpoint: Some(from.finalized_checkpoint),
weight: self.weight, weight: from.weight,
best_child: self.best_child, best_child: from.best_child,
best_descendant: self.best_descendant, best_descendant: from.best_descendant,
execution_status: self.execution_status, execution_status: from.execution_status,
unrealized_justified_checkpoint: self.unrealized_justified_checkpoint, unrealized_justified_checkpoint: from.unrealized_justified_checkpoint,
unrealized_finalized_checkpoint: self.unrealized_finalized_checkpoint, unrealized_finalized_checkpoint: from.unrealized_finalized_checkpoint,
} }
} }
} }

View File

@@ -55,19 +55,19 @@ impl TryInto<SszContainer> for SszContainerV16 {
} }
} }
impl Into<SszContainerV16> for SszContainer { impl From<SszContainer> for SszContainerV16 {
fn into(self) -> SszContainerV16 { fn from(from: SszContainer) -> SszContainerV16 {
let nodes = self.nodes.into_iter().map(Into::into).collect(); let nodes = from.nodes.into_iter().map(Into::into).collect();
SszContainerV16 { SszContainerV16 {
votes: self.votes, votes: from.votes,
balances: self.balances, balances: from.balances,
prune_threshold: self.prune_threshold, prune_threshold: from.prune_threshold,
justified_checkpoint: self.justified_checkpoint, justified_checkpoint: from.justified_checkpoint,
finalized_checkpoint: self.finalized_checkpoint, finalized_checkpoint: from.finalized_checkpoint,
nodes, nodes,
indices: self.indices, indices: from.indices,
previous_proposer_boost: self.previous_proposer_boost, previous_proposer_boost: from.previous_proposer_boost,
} }
} }
} }

View File

@@ -37,9 +37,9 @@ impl From<[u8; GRAFFITI_BYTES_LEN]> for Graffiti {
} }
} }
impl Into<[u8; GRAFFITI_BYTES_LEN]> for Graffiti { impl From<Graffiti> for [u8; GRAFFITI_BYTES_LEN] {
fn into(self) -> [u8; GRAFFITI_BYTES_LEN] { fn from(from: Graffiti) -> [u8; GRAFFITI_BYTES_LEN] {
self.0 from.0
} }
} }
@@ -77,9 +77,9 @@ impl<'de> Deserialize<'de> for GraffitiString {
} }
} }
impl Into<Graffiti> for GraffitiString { impl From<GraffitiString> for Graffiti {
fn into(self) -> Graffiti { fn from(from: GraffitiString) -> Graffiti {
let graffiti_bytes = self.0.as_bytes(); let graffiti_bytes = from.0.as_bytes();
let mut graffiti = [0; GRAFFITI_BYTES_LEN]; let mut graffiti = [0; GRAFFITI_BYTES_LEN];
let graffiti_len = std::cmp::min(graffiti_bytes.len(), GRAFFITI_BYTES_LEN); let graffiti_len = std::cmp::min(graffiti_bytes.len(), GRAFFITI_BYTES_LEN);

View File

@@ -77,9 +77,9 @@ impl SelectionProof {
} }
} }
impl Into<Signature> for SelectionProof { impl From<SelectionProof> for Signature {
fn into(self) -> Signature { fn from(from: SelectionProof) -> Signature {
self.0 from.0
} }
} }

View File

@@ -6,9 +6,9 @@ macro_rules! impl_from_into_u64 {
} }
} }
impl Into<u64> for $main { impl From<$main> for u64 {
fn into(self) -> u64 { fn from(from: $main) -> u64 {
self.0 from.0
} }
} }
@@ -28,9 +28,9 @@ macro_rules! impl_from_into_usize {
} }
} }
impl Into<usize> for $main { impl From<$main> for usize {
fn into(self) -> usize { fn from(from: $main) -> usize {
self.0 as usize from.0 as usize
} }
} }

View File

@@ -150,15 +150,15 @@ impl From<u64> for SubnetId {
} }
} }
impl Into<u64> for SubnetId { impl From<SubnetId> for u64 {
fn into(self) -> u64 { fn from(from: SubnetId) -> u64 {
self.0 from.0
} }
} }
impl Into<u64> for &SubnetId { impl From<&SubnetId> for u64 {
fn into(self) -> u64 { fn from(from: &SubnetId) -> u64 {
self.0 from.0
} }
} }

View File

@@ -90,9 +90,9 @@ impl SyncSelectionProof {
} }
} }
impl Into<Signature> for SyncSelectionProof { impl From<SyncSelectionProof> for Signature {
fn into(self) -> Signature { fn from(from: SyncSelectionProof) -> Signature {
self.0 from.0
} }
} }

View File

@@ -78,15 +78,15 @@ impl From<u64> for SyncSubnetId {
} }
} }
impl Into<u64> for SyncSubnetId { impl From<SyncSubnetId> for u64 {
fn into(self) -> u64 { fn from(from: SyncSubnetId) -> u64 {
self.0 from.0
} }
} }
impl Into<u64> for &SyncSubnetId { impl From<&SyncSubnetId> for u64 {
fn into(self) -> u64 { fn from(from: &SyncSubnetId) -> u64 {
self.0 from.0
} }
} }

View File

@@ -14,9 +14,9 @@ pub enum ChecksumFunction {
Sha256, Sha256,
} }
impl Into<String> for ChecksumFunction { impl From<ChecksumFunction> for String {
fn into(self) -> String { fn from(from: ChecksumFunction) -> String {
match self { match from {
ChecksumFunction::Sha256 => "sha256".into(), ChecksumFunction::Sha256 => "sha256".into(),
} }
} }
@@ -38,8 +38,8 @@ impl TryFrom<String> for ChecksumFunction {
#[serde(try_from = "Value", into = "Value")] #[serde(try_from = "Value", into = "Value")]
pub struct EmptyMap; pub struct EmptyMap;
impl Into<Value> for EmptyMap { impl From<EmptyMap> for Value {
fn into(self) -> Value { fn from(_from: EmptyMap) -> Value {
Value::Object(Map::default()) Value::Object(Map::default())
} }
} }

View File

@@ -13,9 +13,9 @@ pub enum CipherFunction {
Aes128Ctr, Aes128Ctr,
} }
impl Into<String> for CipherFunction { impl From<CipherFunction> for String {
fn into(self) -> String { fn from(from: CipherFunction) -> String {
match self { match from {
CipherFunction::Aes128Ctr => "aes-128-ctr".into(), CipherFunction::Aes128Ctr => "aes-128-ctr".into(),
} }
} }

View File

@@ -25,9 +25,9 @@ impl From<Vec<u8>> for HexBytes {
} }
} }
impl Into<String> for HexBytes { impl From<HexBytes> for String {
fn into(self) -> String { fn from(from: HexBytes) -> String {
hex::encode(self.0) hex::encode(from.0)
} }
} }

View File

@@ -23,8 +23,8 @@ pub struct KdfModule {
#[serde(try_from = "String", into = "String")] #[serde(try_from = "String", into = "String")]
pub struct EmptyString; pub struct EmptyString;
impl Into<String> for EmptyString { impl From<EmptyString> for String {
fn into(self) -> String { fn from(_from: EmptyString) -> String {
"".into() "".into()
} }
} }
@@ -91,9 +91,9 @@ pub enum KdfFunction {
Pbkdf2, Pbkdf2,
} }
impl Into<String> for KdfFunction { impl From<KdfFunction> for String {
fn into(self) -> String { fn from(from: KdfFunction) -> String {
match self { match from {
KdfFunction::Scrypt => "scrypt".into(), KdfFunction::Scrypt => "scrypt".into(),
KdfFunction::Pbkdf2 => "pbkdf2".into(), KdfFunction::Pbkdf2 => "pbkdf2".into(),
} }

View File

@@ -39,9 +39,9 @@ pub enum TypeField {
Hd, Hd,
} }
impl Into<String> for TypeField { impl From<TypeField> for String {
fn into(self) -> String { fn from(from: TypeField) -> String {
match self { match from {
TypeField::Hd => "hierarchical deterministic".into(), TypeField::Hd => "hierarchical deterministic".into(),
} }
} }

View File

@@ -38,9 +38,9 @@ impl From<[u8; BYTES_PER_PROOF]> for KzgProof {
} }
} }
impl Into<[u8; BYTES_PER_PROOF]> for KzgProof { impl From<KzgProof> for [u8; BYTES_PER_PROOF] {
fn into(self) -> [u8; BYTES_PER_PROOF] { fn from(from: KzgProof) -> [u8; BYTES_PER_PROOF] {
self.0 from.0
} }
} }

View File

@@ -67,9 +67,9 @@ impl From<Hash256> for SigningRoot {
} }
} }
impl Into<Hash256> for SigningRoot { impl From<SigningRoot> for Hash256 {
fn into(self) -> Hash256 { fn from(from: SigningRoot) -> Hash256 {
self.0 from.0
} }
} }