Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm generics when useless #12581

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/cli/commands/src/db/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ impl<N: ProviderNodeTypes> TableViewer<(u64, Duration)> for ChecksumViewer<'_, N
let mut cursor = tx.cursor_read::<RawTable<T>>()?;
let walker = match (self.start_key.as_deref(), self.end_key.as_deref()) {
(Some(start), Some(end)) => {
let start_key = table_key::<T>(start).map(RawKey::<T::Key>::new)?;
let end_key = table_key::<T>(end).map(RawKey::<T::Key>::new)?;
let start_key = table_key::<T>(start).map(RawKey::new)?;
let end_key = table_key::<T>(end).map(RawKey::new)?;
cursor.walk_range(start_key..=end_key)?
}
(None, Some(end)) => {
let end_key = table_key::<T>(end).map(RawKey::<T::Key>::new)?;
let end_key = table_key::<T>(end).map(RawKey::new)?;

cursor.walk_range(..=end_key)?
}
(Some(start), None) => {
let start_key = table_key::<T>(start).map(RawKey::<T::Key>::new)?;
let start_key = table_key::<T>(start).map(RawKey::new)?;
cursor.walk_range(start_key..)?
}
(None, None) => cursor.walk_range(..)?,
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ impl Command {

/// Get an instance of key for given table
pub(crate) fn table_key<T: Table>(key: &str) -> Result<T::Key, eyre::Error> {
serde_json::from_str::<T::Key>(key).map_err(|e| eyre::eyre!(e))
serde_json::from_str(key).map_err(|e| eyre::eyre!(e))
}

/// Get an instance of subkey for given dupsort table
fn table_subkey<T: DupSort>(subkey: Option<&str>) -> Result<T::SubKey, eyre::Error> {
serde_json::from_str::<T::SubKey>(subkey.unwrap_or_default()).map_err(|e| eyre::eyre!(e))
serde_json::from_str(subkey.unwrap_or_default()).map_err(|e| eyre::eyre!(e))
}

struct GetValueViewer<'a, N: NodeTypesWithDB> {
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/db/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ where
.map(|(i, k)| {
ListItem::new(format!("[{:0>width$}]: {k:?}", i + app.skip, width = key_length))
})
.collect::<Vec<ListItem<'_>>>();
.collect::<Vec<_>>();

let key_list = List::new(formatted_keys)
.block(Block::default().borders(Borders::ALL).title(format!(
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ where

let max_block = file_client.max_block().unwrap_or(0);

let pipeline = Pipeline::<N>::builder()
let pipeline = Pipeline::builder()
.with_tip_sender(tip_tx)
// we want to sync all blocks the file client provides or 0 if empty
.with_max_block(max_block)
Expand Down
5 changes: 1 addition & 4 deletions crates/cli/util/src/load_secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ pub fn get_secret_key(secret_key_path: &Path) -> Result<SecretKey, SecretKeyErro
match exists {
Ok(true) => {
let contents = fs::read_to_string(secret_key_path)?;
Ok(contents
.as_str()
.parse::<SecretKey>()
.map_err(SecretKeyError::SecretKeyDecodeError)?)
Ok(contents.as_str().parse().map_err(SecretKeyError::SecretKeyDecodeError)?)
}
Ok(false) => {
if let Some(dir) = secret_key_path.parent() {
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/util/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ pub fn parse_duration_from_secs_or_ms(
arg: &str,
) -> eyre::Result<Duration, std::num::ParseIntError> {
if arg.ends_with("ms") {
arg.trim_end_matches("ms").parse::<u64>().map(Duration::from_millis)
arg.trim_end_matches("ms").parse().map(Duration::from_millis)
} else if arg.ends_with('s') {
arg.trim_end_matches('s').parse::<u64>().map(Duration::from_secs)
arg.trim_end_matches('s').parse().map(Duration::from_secs)
} else {
arg.parse::<u64>().map(Duration::from_secs)
arg.parse().map(Duration::from_secs)
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn parse_socket_address(value: &str) -> eyre::Result<SocketAddr, SocketAddre
let port: u16 = port.parse()?;
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port))
}
if let Ok(port) = value.parse::<u16>() {
if let Ok(port) = value.parse() {
return Ok(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port))
}
value
Expand Down
Loading