Skip to content

Commit

Permalink
chore: Optimize code at 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
BinChengZhao committed Jan 8, 2024
1 parent 1ccaac0 commit 194f470
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ smol = "^1.2.5"
concat-idents = "1.1.3"
async-trait = "^0.1.48"
event-listener = "^2.5.1"
log = "^0.4.14"
log = "0.4.14"
tracing = "0.1.29"
thiserror = "^1.0.24"

Expand Down
9 changes: 2 additions & 7 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,16 @@ pub(crate) struct RuntimeInstance {
pub(crate) kind: RuntimeKind,
}
/// Async-Runtime Kind
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
pub enum RuntimeKind {
/// Async-Runtime `smol` compatible with the async-std
Smol,

/// Async-Runtime `tokio`
#[default]
Tokio,
}

impl Default for RuntimeKind {
fn default() -> Self {
RuntimeKind::Tokio
}
}

impl Default for RuntimeInstance {
fn default() -> Self {
let kind = RuntimeKind::Tokio;
Expand Down
2 changes: 1 addition & 1 deletion src/timer/runtime_trace/task_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl TaskTrace {
//entry is amazing!
self.inner
.entry(task_id)
.or_insert_with(LinkedList::new)
.or_default()
.push_back(task_handler_box);
}

Expand Down
10 changes: 3 additions & 7 deletions src/timer/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,12 @@ impl<'a> TryFrom<(FrequencyUnify<'a>, ScheduleIteratorTimeZone)> for FrequencyIn
}

/// Set the time zone for the time of the expression iteration.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Default)]
pub enum ScheduleIteratorTimeZone {
/// Utc specifies the UTC time zone. It is most efficient.
Utc,
/// Local specifies the system local time zone.
#[default]
Local,
/// FixedOffset specifies an arbitrary, fixed time zone such as UTC+09:00 or UTC-10:30. This often results from the parsed textual date and time. Since it stores the most information and does not depend on the system environment, you would want to normalize other TimeZones into this type.
FixedOffset(FixedOffset),
Expand All @@ -283,12 +284,6 @@ impl ScheduleIteratorTimeZone {
}
}

impl Default for ScheduleIteratorTimeZone {
fn default() -> Self {
ScheduleIteratorTimeZone::Local
}
}

/// The Cron-expression scheduling iterator enum.
/// There are three variants.
/// The declaration `enum` is to avoid the problems caused by generalized contagion and monomorphism.
Expand Down Expand Up @@ -547,6 +542,7 @@ type SafeBoxRoutine = Box<
+ Send,
>;

#[allow(dead_code)]
pub(crate) struct SafeStructBoxedFn(pub(crate) SafeBoxFn);
impl fmt::Debug for SafeStructBoxedFn {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
10 changes: 5 additions & 5 deletions src/utils/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ pub mod shell_command {
return None;
};

if let Some(filename) = command.trim().rsplit(angle_bracket).next() {
Some(create_stdio_file(angle_bracket, filename))
} else {
None
}
command
.trim()
.rsplit(angle_bracket)
.next()
.map(|filename| create_stdio_file(angle_bracket, filename))
}

#[cfg(SPLIT_INCLUSIVE_COMPATIBLE)]
Expand Down

0 comments on commit 194f470

Please sign in to comment.