rm generics when useless (#12581)

This commit is contained in:
Thomas Coratger
2024-11-16 05:39:49 +01:00
committed by GitHub
parent 5276093e71
commit c160005531
6 changed files with 13 additions and 16 deletions

View File

@ -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(..)?,

View File

@ -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> {

View File

@ -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!(

View File

@ -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)

View File

@ -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() {

View File

@ -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)
}
}
@ -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