summaryrefslogtreecommitdiff
path: root/src/tasks.rs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-16 21:13:35 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-17 21:28:52 +0800
commita3b597ba7efbf7e0ddbe9d72e7202ea7a6b286a9 (patch)
treeef2ab58378c6f5009f9aa4d8560dd34bb6861f9b /src/tasks.rs
parent368aee800658e9c1a9a30871c45fc6034cceda48 (diff)
perf: use explicit 'a lifetime instead of 'static
Diffstat (limited to 'src/tasks.rs')
-rw-r--r--src/tasks.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tasks.rs b/src/tasks.rs
index ad41a35..1793091 100644
--- a/src/tasks.rs
+++ b/src/tasks.rs
@@ -1,17 +1,17 @@
-pub struct Task {
- pub name: &'static str,
+pub struct Task<'a> {
+ pub name: &'a str,
pub exec: fn(&[String]) -> Result<String, String>,
}
-impl PartialEq for &Task {
+impl<'a> PartialEq for &'a Task<'a> {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
}
}
-pub const TASKS: &[Task] = &[Task { name: "nop", exec: no_op }, Task { name: "exec", exec: exec }, NETWORK_T];
+pub const TASKS: &[Task<'static>] = &[Task { name: "nop", exec: no_op }, Task { name: "exec", exec: exec }, NETWORK_T];
-pub const NETWORK_T: Task = Task { name: "network", exec: network };
+pub const NETWORK_T: Task<'static> = Task { name: "network", exec: network };
fn no_op(_: &[String]) -> Result<String, String> {
Ok("".to_string())
@@ -115,7 +115,7 @@ pub enum IntoTaskErr {
NotFound(String),
}
-impl TryFrom<&str> for &Task {
+impl<'a> TryFrom<&str> for &'a Task<'a> {
type Error = IntoTaskErr;
fn try_from(value: &str) -> Result<Self, Self::Error> {