Skip to content

Commit 0494092

Browse files
committed
Migrate to rand 0.9.0
1 parent 1e0b8af commit 0494092

File tree

4 files changed

+84
-103
lines changed

4 files changed

+84
-103
lines changed

Cargo.lock

+47-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ members = [
2424

2525
[workspace.dependencies]
2626
gix = { version = "0.70.0", default-features = false }
27-
dyn-clone = { version = "1.0.18" }
27+
dyn-clone = { version = "1.0.19" }
2828
comfy-table = { version = "7.1.4" }
2929
termcolor = { version = "1.4.1" }
30-
serde_json = { version = "1.0.139" }
30+
serde_json = { version = "1.0.140" }
3131
csv = { version = "1.3.1" }
32-
chrono = { version = "0.4.39" }
32+
chrono = { version = "0.4.40" }
3333
regex = { version = "1.11.1" }
34-
rand = { version = "0.8.5" }
35-
indexmap = { version = "2.7.1" }
36-
uuid = { version = "1.14.0", features = ["v4"] }
34+
rand = { version = "0.9.0" }
35+
indexmap = { version = "2.8.0" }
36+
uuid = { version = "1.16.0", features = ["v4"] }
3737

3838
[profile.release]
3939
lto = true

crates/gitql-std/src/array/mod.rs

+29-70
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@ pub fn register_std_array_function_signatures(map: &mut HashMap<&'static str, Si
4141
"array_append",
4242
Signature {
4343
parameters: vec![
44-
Box::new(ArrayType {
45-
base: Box::new(AnyType),
46-
}),
44+
Box::new(ArrayType::new(Box::new(AnyType))),
4745
Box::new(DynamicType {
4846
function: |elements| array_element_type(first_element_type(elements)),
4947
}),
5048
],
51-
return_type: Box::new(DynamicType {
52-
function: first_element_type,
53-
}),
49+
return_type: Box::new(DynamicType::new(first_element_type)),
5450
},
5551
);
5652
map.insert(
@@ -62,41 +58,29 @@ pub fn register_std_array_function_signatures(map: &mut HashMap<&'static str, Si
6258
function: |elements| array_of_type(first_element_type(elements)),
6359
}),
6460
],
65-
return_type: Box::new(DynamicType {
66-
function: second_element_type,
67-
}),
61+
return_type: Box::new(DynamicType::new(second_element_type)),
6862
},
6963
);
7064
map.insert(
7165
"array_remove",
7266
Signature {
7367
parameters: vec![
74-
Box::new(ArrayType {
75-
base: Box::new(AnyType),
76-
}),
68+
Box::new(ArrayType::new(Box::new(AnyType))),
7769
Box::new(DynamicType {
7870
function: |elements| array_element_type(first_element_type(elements)),
7971
}),
8072
],
81-
return_type: Box::new(DynamicType {
82-
function: first_element_type,
83-
}),
73+
return_type: Box::new(DynamicType::new(first_element_type)),
8474
},
8575
);
8676
map.insert(
8777
"array_cat",
8878
Signature {
8979
parameters: vec![
90-
Box::new(ArrayType {
91-
base: Box::new(AnyType),
92-
}),
93-
Box::new(DynamicType {
94-
function: first_element_type,
95-
}),
80+
Box::new(ArrayType::new(Box::new(AnyType))),
81+
Box::new(DynamicType::new(first_element_type)),
9682
],
97-
return_type: Box::new(DynamicType {
98-
function: first_element_type,
99-
}),
83+
return_type: Box::new(DynamicType::new(first_element_type)),
10084
},
10185
);
10286
map.insert(
@@ -181,20 +165,18 @@ pub fn array_append(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
181165
let mut array = inputs[0].as_array().unwrap();
182166
let element = &inputs[1];
183167
array.push(element.to_owned());
184-
Box::new(ArrayValue {
185-
values: array,
186-
base_type: inputs[0].data_type().clone(),
187-
})
168+
169+
let element_type = inputs[0].data_type().clone();
170+
Box::new(ArrayValue::new(array, element_type))
188171
}
189172

190173
pub fn array_prepend(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
191174
let element = &inputs[0];
192175
let mut array = inputs[1].as_array().unwrap();
193176
array.insert(0, element.clone());
194-
Box::new(ArrayValue {
195-
values: array,
196-
base_type: inputs[1].data_type().clone(),
197-
})
177+
178+
let element_type = inputs[0].data_type().clone();
179+
Box::new(ArrayValue::new(array, element_type))
198180
}
199181

200182
pub fn array_remove(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
@@ -204,10 +186,9 @@ pub fn array_remove(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
204186
.into_iter()
205187
.filter(|element| !element_to_remove.equals(element))
206188
.collect();
207-
Box::new(ArrayValue {
208-
values: array_after_remove,
209-
base_type: inputs[0].data_type().clone(),
210-
})
189+
190+
let element_type = inputs[0].data_type().clone();
191+
Box::new(ArrayValue::new(array_after_remove, element_type))
211192
}
212193

213194
pub fn array_cat(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
@@ -216,16 +197,15 @@ pub fn array_cat(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
216197
let mut result = Vec::with_capacity(first.len() + other.len());
217198
result.append(&mut first);
218199
result.append(&mut other);
219-
Box::new(ArrayValue {
220-
values: result,
221-
base_type: inputs[0].data_type().clone(),
222-
})
200+
201+
let element_type = inputs[0].data_type().clone();
202+
Box::new(ArrayValue::new(result, element_type))
223203
}
224204

225205
pub fn array_length(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
226206
let array = inputs[0].as_array().unwrap();
227207
let value = array.len() as i64;
228-
Box::new(IntValue { value })
208+
Box::new(IntValue::new(value))
229209
}
230210

231211
pub fn array_shuffle(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
@@ -235,24 +215,17 @@ pub fn array_shuffle(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
235215
.downcast_ref::<ArrayType>()
236216
.unwrap()
237217
.base;
238-
239218
let mut array = inputs[0].as_array().unwrap();
240-
array.shuffle(&mut rand::thread_rng());
241-
Box::new(ArrayValue {
242-
values: array,
243-
base_type: element_type.clone(),
244-
})
219+
array.shuffle(&mut rand::rng());
220+
Box::new(ArrayValue::new(array, element_type.clone()))
245221
}
246222

247223
pub fn array_position(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
248224
let array = inputs[0].as_array().unwrap();
249225
let elemnet = &inputs[1];
250226
if let Some(index) = array.iter().position(|r| r.equals(elemnet)) {
251-
return Box::new(IntValue {
252-
value: (index + 1) as i64,
253-
});
227+
return Box::new(IntValue::new((index + 1) as i64));
254228
}
255-
256229
Box::new(NullValue)
257230
}
258231

@@ -262,22 +235,15 @@ pub fn array_positions(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
262235
let mut positions: Vec<Box<dyn Value>> = vec![];
263236
for (index, element) in array.into_iter().enumerate() {
264237
if element.equals(target) {
265-
positions.push(Box::new(IntValue {
266-
value: (index + 1) as i64,
267-
}));
238+
positions.push(Box::new(IntValue::new((index + 1) as i64)));
268239
}
269240
}
270-
Box::new(ArrayValue {
271-
values: positions,
272-
base_type: Box::new(IntType),
273-
})
241+
Box::new(ArrayValue::new(positions, Box::new(IntType)))
274242
}
275243

276244
pub fn array_dims(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
277245
let array_type = inputs[0].data_type();
278-
Box::new(TextValue {
279-
value: array_type.to_string(),
280-
})
246+
Box::new(TextValue::new(array_type.to_string()))
281247
}
282248

283249
pub fn array_replace(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
@@ -290,11 +256,7 @@ pub fn array_replace(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
290256
*element = to.clone();
291257
}
292258
}
293-
294-
Box::new(ArrayValue {
295-
values: array_values,
296-
base_type: array_type,
297-
})
259+
Box::new(ArrayValue::new(array_values, array_type))
298260
}
299261

300262
pub fn array_trim(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
@@ -303,8 +265,5 @@ pub fn array_trim(inputs: &[Box<dyn Value>]) -> Box<dyn Value> {
303265
let array_len = array.len();
304266
let n = i64::min(array.len().try_into().unwrap(), inputs[1].as_int().unwrap());
305267
array.truncate(array_len - n as usize);
306-
Box::new(ArrayValue {
307-
values: array,
308-
base_type: array_type,
309-
})
268+
Box::new(ArrayValue::new(array, array_type))
310269
}

0 commit comments

Comments
 (0)