Skip to content

Commit

Permalink
lint: fix clippy and fmt issues
Browse files Browse the repository at this point in the history
Signed-off-by: Amin Yahyaabadi <aminyahyaabadi74@gmail.com>
  • Loading branch information
aminya committed Nov 19, 2023
1 parent f0607ac commit 02e1115
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Among them, each task may produce output, and may also require the output of som

### Programmatically implement task definition

Users need to program to implement the `Action` trait to define the specific logic of the task, and then build a series of `DefaultTask`.
Users need to program to implement the `Action` trait to define the specific logic of the task, and then build a series of `DefaultTask`.

First, users need to define some specific task logic. There are two ways to define task logic:

Expand All @@ -70,7 +70,7 @@ Finally, don’t forget to initialize the logger, and then you can call the `sta
You can refer to an example for the above complete steps: `examples/compute_dag.rs`


Here is the `examples/impl_action.rs` example:
Here is the `examples/compute_dag.rs` example:

```rust
//! Only use Dag, execute a job. The graph is as follows:
Expand Down
2 changes: 1 addition & 1 deletion examples/compute_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
extern crate dagrs;

use std::sync::Arc;
use dagrs::{log, Complex, Dag, DefaultTask, EnvVar, Input, LogLevel, Output};
use std::sync::Arc;

struct Compute(usize);

Expand Down
6 changes: 3 additions & 3 deletions examples/custom_parser_and_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ impl ConfigParser {
}

fn parse_one(&self, item: String) -> MyTask {
let attr: Vec<&str> = item.split(",").collect();
let attr: Vec<&str> = item.split(',').collect();

let pres_item = *attr.get(2).unwrap();
let pres = if pres_item.eq("") {
Vec::new()
} else {
pres_item.split(" ").map(|pre| pre.to_string()).collect()
pres_item.split(' ').map(|pre| pre.to_string()).collect()
};

let id = *attr.get(0).unwrap();
let id = *attr.first().unwrap();
let name = attr.get(1).unwrap().to_string();
let cmd = *attr.get(3).unwrap();
MyTask::new(id, pres, name, CommandAction::new(cmd))
Expand Down
8 changes: 4 additions & 4 deletions examples/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ fn main() {
g ->
);
let mut x = 1;
for index in 0..4 {
tasks[index].set_action(Compute(x * 2));
for task in tasks.iter_mut().take(4) {
task.set_action(Compute(x * 2));
x *= 2;
}

for index in 4..7 {
tasks[index].set_closure(|input, env| {
for task in tasks.iter_mut().skip(4) {
task.set_closure(|input, env| {
let base = env.get::<usize>("base").unwrap();
let mut sum = 0;
input
Expand Down
3 changes: 2 additions & 1 deletion tests/dag_job_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Some tests of the dag engine.
use std::{collections::HashMap, sync::Arc};

///! Some tests of the dag engine.
use dagrs::{log, Complex, Dag, DagError, DefaultTask, EnvVar, Input, LogLevel, Output};

#[test]
Expand Down

0 comments on commit 02e1115

Please sign in to comment.