Skip to content

Commit 54c7bbb

Browse files
committed
ref: cargo fmt
1 parent b8b42a9 commit 54c7bbb

File tree

12 files changed

+1143
-314
lines changed

12 files changed

+1143
-314
lines changed

taurus/src/context/argument.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::convert::Infallible;
2-
use tucana::shared::{ListValue, Struct, Value};
3-
use tucana::shared::value::Kind;
41
use crate::context::signal::Signal;
52
use crate::error::RuntimeError;
3+
use std::convert::Infallible;
4+
use tucana::shared::value::Kind;
5+
use tucana::shared::{ListValue, Struct, Value};
66

77
#[derive(Clone, Debug)]
88
pub enum Argument {
@@ -11,21 +11,24 @@ pub enum Argument {
1111
Eval(tucana::shared::Value),
1212
// Thunk of NodeFunction identifier
1313
// - used for lazy execution of nodes
14-
Thunk(i64)
14+
Thunk(i64),
1515
}
1616

1717
#[derive(Clone, Copy, Debug)]
1818
pub enum ParameterNode {
1919
Eager,
20-
Lazy
20+
Lazy,
2121
}
2222

2323
pub trait TryFromArgument: Sized {
2424
fn try_from_argument(a: &Argument) -> Result<Self, Signal>;
2525
}
2626

2727
fn type_err(msg: &str) -> Signal {
28-
Signal::Failure(RuntimeError::simple("InvalidArgumentRuntimeError", msg.to_string()))
28+
Signal::Failure(RuntimeError::simple(
29+
"InvalidArgumentRuntimeError",
30+
msg.to_string(),
31+
))
2932
}
3033

3134
impl TryFromArgument for Value {
@@ -40,7 +43,9 @@ impl TryFromArgument for Value {
4043
impl TryFromArgument for f64 {
4144
fn try_from_argument(a: &Argument) -> Result<Self, Signal> {
4245
match a {
43-
Argument::Eval(Value { kind: Some(Kind::NumberValue(n)) }) => Ok(*n),
46+
Argument::Eval(Value {
47+
kind: Some(Kind::NumberValue(n)),
48+
}) => Ok(*n),
4449
_ => Err(type_err("Expected number")),
4550
}
4651
}
@@ -49,7 +54,9 @@ impl TryFromArgument for f64 {
4954
impl TryFromArgument for bool {
5055
fn try_from_argument(a: &Argument) -> Result<Self, Signal> {
5156
match a {
52-
Argument::Eval(Value { kind: Some(Kind::BoolValue(b)) }) => Ok(*b),
57+
Argument::Eval(Value {
58+
kind: Some(Kind::BoolValue(b)),
59+
}) => Ok(*b),
5360
_ => Err(type_err("Expected boolean")),
5461
}
5562
}
@@ -58,7 +65,9 @@ impl TryFromArgument for bool {
5865
impl TryFromArgument for String {
5966
fn try_from_argument(a: &Argument) -> Result<Self, Signal> {
6067
match a {
61-
Argument::Eval(Value { kind: Some(Kind::StringValue(s)) }) => Ok(s.clone()),
68+
Argument::Eval(Value {
69+
kind: Some(Kind::StringValue(s)),
70+
}) => Ok(s.clone()),
6271
_ => Err(type_err("Expected string")),
6372
}
6473
}
@@ -67,7 +76,9 @@ impl TryFromArgument for String {
6776
impl TryFromArgument for Struct {
6877
fn try_from_argument(a: &Argument) -> Result<Self, Signal> {
6978
match a {
70-
Argument::Eval(Value { kind: Some(Kind::StructValue(s)) }) => Ok(s.clone()),
79+
Argument::Eval(Value {
80+
kind: Some(Kind::StructValue(s)),
81+
}) => Ok(s.clone()),
7182
_ => Err(type_err("Expected struct")),
7283
}
7384
}
@@ -76,7 +87,9 @@ impl TryFromArgument for Struct {
7687
impl TryFromArgument for ListValue {
7788
fn try_from_argument(a: &Argument) -> Result<Self, Signal> {
7889
match a {
79-
Argument::Eval(Value { kind: Some(Kind::ListValue(list)) }) => Ok(list.clone()),
90+
Argument::Eval(Value {
91+
kind: Some(Kind::ListValue(list)),
92+
}) => Ok(list.clone()),
8093
_ => Err(Signal::Failure(RuntimeError::simple_str(
8194
"InvalidArgumentRuntimeError",
8295
"Expected array (ListValue)",
@@ -89,4 +102,4 @@ impl From<Infallible> for RuntimeError {
89102
fn from(never: Infallible) -> Self {
90103
match never {}
91104
}
92-
}
105+
}

taurus/src/context/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::context::signal::Signal;
55
use crate::error::RuntimeError;
66
use std::cell::RefCell;
77
use std::collections::HashMap;
8-
use tucana::shared::{NodeFunction};
8+
use tucana::shared::NodeFunction;
99

1010
pub struct Executor<'a> {
1111
functions: &'a FunctionStore,

taurus/src/context/macros.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ macro_rules! args {
3131
macro_rules! no_args {
3232
($args_ident:ident) => {
3333
if !$args_ident.is_empty() {
34-
return $crate::context::signal::Signal::Failure(
35-
$crate::error::RuntimeError::simple(
36-
"InvalidArgumentRuntimeError",
37-
format!("Expected 0 args but received {}", $args_ident.len()),
38-
)
39-
);
34+
return $crate::context::signal::Signal::Failure($crate::error::RuntimeError::simple(
35+
"InvalidArgumentRuntimeError",
36+
format!("Expected 0 args but received {}", $args_ident.len()),
37+
));
4038
}
4139
};
4240
}
4341

4442
pub(crate) use args;
45-
pub(crate) use no_args;
43+
pub(crate) use no_args;

taurus/src/context/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
pub mod context;
2-
pub mod signal;
31
pub mod argument;
2+
pub mod context;
43
pub mod executor;
5-
pub mod registry;
64
pub mod macros;
5+
pub mod registry;
6+
pub mod signal;
77

88
use crate::error::RuntimeError;
99
use std::{

0 commit comments

Comments
 (0)