Skip to content

Commit 37bb8f8

Browse files
committed
refactor: Switch to derive_more for convenience
1 parent 6231c21 commit 37bb8f8

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
alloy = "0.9.2"
8+
derive_more = "1.0.0"
89
hex = "0.4.3"
910
# `bundled` causes us to automatically compile and link in an up to date
1011
# version of SQLite for you. This avoids many common build issues, and

src/sqlite.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use rusqlite::types::ToSqlOutput;
66
use serde::{Serialize, Deserialize};
77
use thiserror::Error;
88
use alloy::primitives::{Address, keccak256};
9-
use std::str::FromStr;
9+
use derive_more::{From, Display, FromStr};
1010

11-
#[derive(Debug, Clone, Copy)]
11+
#[derive(Debug, Clone, Copy, From, Display, FromStr)]
12+
#[display("{}", _0)]
1213
struct AddressSqlite(Address);
1314

1415
impl ToSql for AddressSqlite {
@@ -17,18 +18,6 @@ impl ToSql for AddressSqlite {
1718
}
1819
}
1920

20-
impl From<Address> for AddressSqlite {
21-
fn from(addr: Address) -> Self {
22-
AddressSqlite(addr)
23-
}
24-
}
25-
26-
impl From<AddressSqlite> for Address {
27-
fn from(addr: AddressSqlite) -> Self {
28-
addr.0
29-
}
30-
}
31-
3221
impl rusqlite::types::FromSql for AddressSqlite {
3322
fn column_result(value: rusqlite::types::ValueRef<'_>) -> rusqlite::types::FromSqlResult<Self> {
3423
match value {

0 commit comments

Comments
 (0)