Skip to content

Commit

Permalink
Clippy Fixes for Rust Version 1.83.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AmmarAbouZor committed Dec 3, 2024
1 parent 0bbbd0a commit 63dfbc9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
1 change: 0 additions & 1 deletion application/apps/indexer/indexer_base/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn is_newline(c: char) -> bool {
}

#[inline]

pub fn number_string_len(linenr: usize) -> usize {
if linenr == 0 {
return 1;
Expand Down
22 changes: 11 additions & 11 deletions application/apps/indexer/parsers/src/dlt/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn try_new_from_fibex_message_info(message_info: &str) -> Option<MessageType> {

struct DltMessageType<'a>(&'a MessageType);

impl<'a> fmt::Display for DltMessageType<'a> {
impl fmt::Display for DltMessageType<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match &self.0 {
MessageType::ApplicationTrace(app_type) => write!(f, "{} ", app_type.as_ref()),
Expand All @@ -71,7 +71,7 @@ impl<'a> fmt::Display for DltMessageType<'a> {
// EColumn.DATETIME,
// EColumn.ECUID,
struct DltStorageHeader<'a>(&'a StorageHeader);
impl<'a> fmt::Display for DltStorageHeader<'a> {
impl fmt::Display for DltStorageHeader<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
write!(
f,
Expand All @@ -85,7 +85,7 @@ impl<'a> fmt::Display for DltStorageHeader<'a> {

struct DltValue<'a>(&'a Value);

impl<'a> fmt::Display for DltValue<'a> {
impl fmt::Display for DltValue<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match &self.0 {
Value::Bool(value) => value.fmt(f),
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'a> fmt::Display for DltValue<'a> {

struct DltArgument<'a>(&'a Argument);

impl<'a> fmt::Display for DltArgument<'a> {
impl fmt::Display for DltArgument<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
if let Some(n) = &self.0.name {
write!(f, "{n}")?;
Expand All @@ -134,7 +134,7 @@ impl<'a> fmt::Display for DltArgument<'a> {

struct DltDltTimeStamp<'a>(&'a DltTimeStamp);

impl<'a> fmt::Display for DltDltTimeStamp<'a> {
impl fmt::Display for DltDltTimeStamp<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
let dt: Option<DateTime<Utc>> =
DateTime::from_timestamp(i64::from(self.0.seconds), self.0.microseconds * 1000);
Expand All @@ -156,7 +156,7 @@ impl<'a> fmt::Display for DltDltTimeStamp<'a> {
// EColumn.ECUID,
struct DltStandardHeader<'a>(&'a StandardHeader);

impl<'a> fmt::Display for DltStandardHeader<'a> {
impl fmt::Display for DltStandardHeader<'_> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
write!(f, "{}{}", self.0.version, DLT_COLUMN_SENTINAL)?;
if let Some(id) = &self.0.session_id {
Expand Down Expand Up @@ -203,7 +203,7 @@ pub struct FormattableMessage<'a> {
pub options: Option<&'a FormatOptions>,
}

impl<'a> Serialize for FormattableMessage<'a> {
impl Serialize for FormattableMessage<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down Expand Up @@ -300,7 +300,7 @@ impl<'a> Serialize for FormattableMessage<'a> {
}
}

impl<'a> From<Message> for FormattableMessage<'a> {
impl From<Message> for FormattableMessage<'_> {
fn from(message: Message) -> Self {
FormattableMessage {
message,
Expand Down Expand Up @@ -334,14 +334,14 @@ impl<'a> PrintableMessage<'a> {
}
}

impl<'a> FormattableMessage<'a> {
impl FormattableMessage<'_> {
pub fn printable_parts<'b>(
&'b self,
ext_h_app_id: &'b str,
ext_h_ctx_id: Option<&'b str>,
ext_h_msg_type: Option<MessageType>,
empty: &'b str,
) -> Result<PrintableMessage, fmt::Error> {
) -> Result<PrintableMessage<'b>, fmt::Error> {
let eh_ctx_id: &str = ext_h_ctx_id.unwrap_or(empty);
match &self.message.payload {
PayloadContent::Verbose(arguments) => {
Expand Down Expand Up @@ -539,7 +539,7 @@ impl<'a> FormattableMessage<'a> {
}
}

impl<'a> fmt::Display for FormattableMessage<'a> {
impl fmt::Display for FormattableMessage<'_> {
/// will format dlt Message with those fields:
/// ********* storage-header ********
/// date-time
Expand Down
18 changes: 2 additions & 16 deletions application/apps/indexer/session/src/state/indexes/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,7 @@ impl Map {
);
(updated, after_pos)
} else {
let updated = cmp::max(
before_pos + 1,
if after_pos >= offset {
after_pos - offset
} else {
0
},
);
let updated = cmp::max(before_pos + 1, after_pos.saturating_sub(offset));
self.insert_range(
RangeInclusive::new(updated, after_pos - 1),
Nature::BREADCRUMB.union(Nature::EXPANDED),
Expand Down Expand Up @@ -542,14 +535,7 @@ impl Map {
} else {
// before.is_none() && after.is_some()
let after_pos = Option::unwrap(after);
let updated = cmp::max(
seporator + 1,
if after_pos >= offset {
after_pos - offset
} else {
0
},
);
let updated = cmp::max(seporator + 1, after_pos.saturating_sub(offset));
self.insert_range(
RangeInclusive::new(updated, after_pos - 1),
Nature::BREADCRUMB.union(Nature::EXPANDED),
Expand Down
6 changes: 1 addition & 5 deletions application/apps/indexer/sources/src/binary/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ impl<R: Read + Send + Sync + Seek> ByteSource for BinaryByteSource<R> {
.map_err(|e| SourceError::Unrecoverable(format!("Could not fill buffer: {e}")))?;
content.len()
};
let newly_loaded_bytes = if available > initial_buf_len {
available - initial_buf_len
} else {
0
};
let newly_loaded_bytes = available.saturating_sub(initial_buf_len);
trace!(
"after: capacity: {} (newly loaded: {})",
self.reader.capacity(),
Expand Down
4 changes: 1 addition & 3 deletions cli/src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,7 @@ impl Target {
}
}

/// Performs build process without checking the current builds states
/// Perform any needed copy operation after the build is done
/// Performs any needed copy operation after the build is done
pub async fn after_build(
&self,
prod: bool,
Expand Down

0 comments on commit 63dfbc9

Please sign in to comment.