Skip to content

Commit c692a6f

Browse files
committed
Fix clippy errors
1 parent 25d24d2 commit c692a6f

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

src/common/ttl_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ where
9494
shard.insert(key);
9595
}
9696
BucketOp::Clear => {
97-
let keys_to_delete = mem::replace(&mut shard, HashSet::new());
97+
let keys_to_delete = mem::take(&mut shard);
9898
for key in keys_to_delete {
9999
data.remove(&key);
100100
}
@@ -253,14 +253,14 @@ where
253253

254254
/// run_gc_loop will continuously clear expired entries from the map, checking every `period`. The
255255
/// function terminates if `shutdown` is signalled.
256-
async fn run_gc_loop(time: Arc<AtomicU64>, period: Duration, buckets: &Vec<Bucket<K>>) {
256+
async fn run_gc_loop(time: Arc<AtomicU64>, period: Duration, buckets: &[Bucket<K>]) {
257257
loop {
258258
tokio::time::sleep(period).await;
259259
Self::gc(time.clone(), buckets);
260260
}
261261
}
262262

263-
fn gc(time: Arc<AtomicU64>, buckets: &Vec<Bucket<K>>) {
263+
fn gc(time: Arc<AtomicU64>, buckets: &[Bucket<K>]) {
264264
let index = time.load(std::sync::atomic::Ordering::SeqCst) % buckets.len() as u64;
265265
buckets[index as usize].clear();
266266
time.fetch_add(1, std::sync::atomic::Ordering::SeqCst);

src/config_extension_ext.rs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl ConfigExtensionExt for SessionConfig {
167167
if key.starts_with(&prefix) {
168168
found_some = true;
169169
result.set(
170-
&key.trim_start_matches(&prefix),
170+
key.trim_start_matches(&prefix),
171171
v.to_str().map_err(|err| {
172172
internal_datafusion_err!("Cannot parse header value: {err}")
173173
})?,
@@ -236,10 +236,11 @@ mod tests {
236236
fn test_propagation() -> Result<(), Box<dyn std::error::Error>> {
237237
let mut config = SessionConfig::new();
238238

239-
let mut opt = CustomExtension::default();
240-
opt.foo = "foo".to_string();
241-
opt.bar = 1;
242-
opt.baz = true;
239+
let opt = CustomExtension {
240+
foo: "".to_string(),
241+
bar: 0,
242+
baz: false,
243+
};
243244

244245
config.add_distributed_option_extension(opt)?;
245246
let metadata = config.get_extension::<ContextGrpcMetadata>().unwrap();
@@ -283,12 +284,16 @@ mod tests {
283284
fn test_new_extension_overwrites_previous() -> Result<(), Box<dyn std::error::Error>> {
284285
let mut config = SessionConfig::new();
285286

286-
let mut opt1 = CustomExtension::default();
287-
opt1.foo = "first".to_string();
287+
let opt1 = CustomExtension {
288+
foo: "first".to_string(),
289+
..Default::default()
290+
};
288291
config.add_distributed_option_extension(opt1)?;
289292

290-
let mut opt2 = CustomExtension::default();
291-
opt2.bar = 42;
293+
let opt2 = CustomExtension {
294+
bar: 42,
295+
..Default::default()
296+
};
292297
config.add_distributed_option_extension(opt2)?;
293298

294299
let flight_metadata = config.get_extension::<ContextGrpcMetadata>().unwrap();
@@ -335,13 +340,17 @@ mod tests {
335340
fn test_multiple_extensions_different_prefixes() -> Result<(), Box<dyn std::error::Error>> {
336341
let mut config = SessionConfig::new();
337342

338-
let mut custom_opt = CustomExtension::default();
339-
custom_opt.foo = "custom_value".to_string();
340-
custom_opt.bar = 123;
343+
let custom_opt = CustomExtension {
344+
foo: "custom_value".to_string(),
345+
bar: 123,
346+
..Default::default()
347+
};
341348

342-
let mut another_opt = AnotherExtension::default();
343-
another_opt.setting1 = "other".to_string();
344-
another_opt.setting2 = 456;
349+
let another_opt = AnotherExtension {
350+
setting1: "other".to_string(),
351+
setting2: 456,
352+
..Default::default()
353+
};
345354

346355
config.add_distributed_option_extension(custom_opt)?;
347356
config.add_distributed_option_extension(another_opt)?;
@@ -371,8 +380,8 @@ mod tests {
371380
);
372381

373382
let mut new_config = SessionConfig::new();
374-
new_config.retrieve_distributed_option_extension::<CustomExtension>(&metadata)?;
375-
new_config.retrieve_distributed_option_extension::<AnotherExtension>(&metadata)?;
383+
new_config.retrieve_distributed_option_extension::<CustomExtension>(metadata)?;
384+
new_config.retrieve_distributed_option_extension::<AnotherExtension>(metadata)?;
376385

377386
let propagated_custom = get_ext::<CustomExtension>(&new_config);
378387
let propagated_another = get_ext::<AnotherExtension>(&new_config);

0 commit comments

Comments
 (0)