Skip to content

Commit 826f72a

Browse files
committed
ref: formatting the project
1 parent 7b4a6d4 commit 826f72a

3 files changed

Lines changed: 105 additions & 74 deletions

File tree

src/implementation/mod.rs

Lines changed: 101 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use tucana::shared::{value::Kind, Value};
1+
use tucana::shared::{Value, value::Kind};
22

33
use crate::{context::Context, error::RuntimeError, registry::HandlerFn};
44

@@ -20,13 +20,16 @@ pub fn collect() -> Vec<(&'static str, HandlerFn)> {
2020
}
2121

2222
fn add(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
23-
let [Value {
24-
kind: Some(Kind::NumberValue(lhs)),
25-
..
26-
}, Value {
27-
kind: Some(Kind::NumberValue(rhs)),
28-
..
29-
}] = values
23+
let [
24+
Value {
25+
kind: Some(Kind::NumberValue(lhs)),
26+
..
27+
},
28+
Value {
29+
kind: Some(Kind::NumberValue(rhs)),
30+
..
31+
},
32+
] = values
3033
else {
3134
return Err(RuntimeError::default());
3235
};
@@ -37,13 +40,16 @@ fn add(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
3740
}
3841

3942
fn multiply(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
40-
let [Value {
41-
kind: Some(Kind::NumberValue(lhs)),
42-
..
43-
}, Value {
44-
kind: Some(Kind::NumberValue(rhs)),
45-
..
46-
}] = values
43+
let [
44+
Value {
45+
kind: Some(Kind::NumberValue(lhs)),
46+
..
47+
},
48+
Value {
49+
kind: Some(Kind::NumberValue(rhs)),
50+
..
51+
},
52+
] = values
4753
else {
4854
return Err(RuntimeError::default());
4955
};
@@ -54,13 +60,16 @@ fn multiply(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError>
5460
}
5561

5662
fn substract(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
57-
let [Value {
58-
kind: Some(Kind::NumberValue(lhs)),
59-
..
60-
}, Value {
61-
kind: Some(Kind::NumberValue(rhs)),
62-
..
63-
}] = values
63+
let [
64+
Value {
65+
kind: Some(Kind::NumberValue(lhs)),
66+
..
67+
},
68+
Value {
69+
kind: Some(Kind::NumberValue(rhs)),
70+
..
71+
},
72+
] = values
6473
else {
6574
return Err(RuntimeError::default());
6675
};
@@ -71,13 +80,16 @@ fn substract(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError
7180
}
7281

7382
fn devide(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
74-
let [Value {
75-
kind: Some(Kind::NumberValue(lhs)),
76-
..
77-
}, Value {
78-
kind: Some(Kind::NumberValue(rhs)),
79-
..
80-
}] = values
83+
let [
84+
Value {
85+
kind: Some(Kind::NumberValue(lhs)),
86+
..
87+
},
88+
Value {
89+
kind: Some(Kind::NumberValue(rhs)),
90+
..
91+
},
92+
] = values
8193
else {
8294
return Err(RuntimeError::default());
8395
};
@@ -88,13 +100,16 @@ fn devide(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
88100
}
89101

90102
fn modulo(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
91-
let [Value {
92-
kind: Some(Kind::NumberValue(lhs)),
93-
..
94-
}, Value {
95-
kind: Some(Kind::NumberValue(rhs)),
96-
..
97-
}] = values
103+
let [
104+
Value {
105+
kind: Some(Kind::NumberValue(lhs)),
106+
..
107+
},
108+
Value {
109+
kind: Some(Kind::NumberValue(rhs)),
110+
..
111+
},
112+
] = values
98113
else {
99114
return Err(RuntimeError::default());
100115
};
@@ -105,10 +120,12 @@ fn modulo(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
105120
}
106121

107122
fn abs(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
108-
let [Value {
109-
kind: Some(Kind::NumberValue(value)),
110-
..
111-
}] = values
123+
let [
124+
Value {
125+
kind: Some(Kind::NumberValue(value)),
126+
..
127+
},
128+
] = values
112129
else {
113130
return Err(RuntimeError::default());
114131
};
@@ -119,10 +136,12 @@ fn abs(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
119136
}
120137

121138
fn is_positive(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
122-
let [Value {
123-
kind: Some(Kind::NumberValue(value)),
124-
..
125-
}] = values
139+
let [
140+
Value {
141+
kind: Some(Kind::NumberValue(value)),
142+
..
143+
},
144+
] = values
126145
else {
127146
return Err(RuntimeError::default());
128147
};
@@ -133,13 +152,16 @@ fn is_positive(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeErr
133152
}
134153

135154
fn is_greater(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
136-
let [Value {
137-
kind: Some(Kind::NumberValue(lhs)),
138-
..
139-
}, Value {
140-
kind: Some(Kind::NumberValue(rhs)),
141-
..
142-
}] = values
155+
let [
156+
Value {
157+
kind: Some(Kind::NumberValue(lhs)),
158+
..
159+
},
160+
Value {
161+
kind: Some(Kind::NumberValue(rhs)),
162+
..
163+
},
164+
] = values
143165
else {
144166
return Err(RuntimeError::default());
145167
};
@@ -150,13 +172,16 @@ fn is_greater(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeErro
150172
}
151173

152174
fn is_less(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
153-
let [Value {
154-
kind: Some(Kind::NumberValue(lhs)),
155-
..
156-
}, Value {
157-
kind: Some(Kind::NumberValue(rhs)),
158-
..
159-
}] = values
175+
let [
176+
Value {
177+
kind: Some(Kind::NumberValue(lhs)),
178+
..
179+
},
180+
Value {
181+
kind: Some(Kind::NumberValue(rhs)),
182+
..
183+
},
184+
] = values
160185
else {
161186
return Err(RuntimeError::default());
162187
};
@@ -167,10 +192,12 @@ fn is_less(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError>
167192
}
168193

169194
fn is_zero(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
170-
let [Value {
171-
kind: Some(Kind::NumberValue(value)),
172-
..
173-
}] = values
195+
let [
196+
Value {
197+
kind: Some(Kind::NumberValue(value)),
198+
..
199+
},
200+
] = values
174201
else {
175202
return Err(RuntimeError::default());
176203
};
@@ -181,10 +208,12 @@ fn is_zero(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError>
181208
}
182209

183210
fn from_text(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
184-
let [Value {
185-
kind: Some(Kind::StringValue(string_value)),
186-
..
187-
}] = values
211+
let [
212+
Value {
213+
kind: Some(Kind::StringValue(string_value)),
214+
..
215+
},
216+
] = values
188217
else {
189218
return Err(RuntimeError::default());
190219
};
@@ -200,10 +229,12 @@ fn from_text(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError
200229
}
201230

202231
fn as_text(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
203-
let [Value {
204-
kind: Some(Kind::NumberValue(value)),
205-
..
206-
}] = values
232+
let [
233+
Value {
234+
kind: Some(Kind::NumberValue(value)),
235+
..
236+
},
237+
] = values
207238
else {
208239
return Err(RuntimeError::default());
209240
};

src/locale/locale.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::{
22
collections::HashMap,
3-
fs::{self, read_dir, DirEntry},
3+
fs::{self, DirEntry, read_dir},
44
};
55

66
use serde::Deserialize;
77
use tucana::shared::Translation;
88

9-
use super::code::{code_from_file_name, CountryCode};
9+
use super::code::{CountryCode, code_from_file_name};
1010

1111
#[derive(Debug)]
1212
pub struct Locale {

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn handle_message(message: Message, store: &FunctionStore) -> Result<Message, la
142142
timestamp: message.timestamp,
143143
sender: message.sender,
144144
body: res,
145-
})
145+
});
146146
}
147147
Err(_) => {
148148
todo!("")
@@ -155,7 +155,7 @@ fn handle_message(message: Message, store: &FunctionStore) -> Result<Message, la
155155
timestamp: message.timestamp,
156156
sender: message.sender,
157157
body: runtime_error.to_string(),
158-
})
158+
});
159159
}
160160
}
161161
};

0 commit comments

Comments
 (0)