Skip to content

Commit acb6b1b

Browse files
committed
sim-rs: update rust edition
1 parent 695f77d commit acb6b1b

File tree

17 files changed

+44
-41
lines changed

17 files changed

+44
-41
lines changed

sim-rs/sim-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sim-cli"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
default-run = "sim-cli"
66
rust-version = "1.88"
77

sim-rs/sim-cli/src/bin/gen-test-data/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use anyhow::Result;
44
use clap::{Parser, Subcommand};
55
use sim_core::config::Topology;
66
use strategy::{
7-
globe, organic, random_graph, simplified, GlobeArgs, OrganicArgs, RandomGraphArgs,
8-
SimplifiedArgs,
7+
GlobeArgs, OrganicArgs, RandomGraphArgs, SimplifiedArgs, globe, organic, random_graph,
8+
simplified,
99
};
1010

1111
mod strategy;

sim-rs/sim-cli/src/bin/gen-test-data/strategy/globe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use std::{
33
path::PathBuf,
44
};
55

6-
use anyhow::{bail, Result};
6+
use anyhow::{Result, bail};
77
use clap::Parser;
8-
use rand::{seq::IndexedRandom as _, Rng as _};
8+
use rand::{Rng as _, seq::IndexedRandom as _};
99
use serde::Deserialize;
1010

11-
use crate::strategy::utils::{distribute_stake, GraphBuilder, RawNodeConfig, Weight};
11+
use crate::strategy::utils::{GraphBuilder, RawNodeConfig, Weight, distribute_stake};
1212

1313
#[derive(Debug, Parser)]
1414
pub struct GlobeArgs {
@@ -173,7 +173,7 @@ fn track_connections(connected: &mut BTreeSet<usize>, graph: &GraphBuilder, from
173173
mod tests {
174174
use sim_core::config::Topology;
175175

176-
use super::{globe, GlobeArgs};
176+
use super::{GlobeArgs, globe};
177177

178178
#[test]
179179
fn should_generate_valid_graph() {

sim-rs/sim-cli/src/bin/gen-test-data/strategy/organic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::time::Duration;
22

3-
use anyhow::{bail, Result};
3+
use anyhow::{Result, bail};
44
use clap::Parser;
5-
use rand::{seq::SliceRandom, Rng};
5+
use rand::{Rng, seq::SliceRandom};
66

77
use crate::strategy::utils::GraphBuilder;
88

9-
use super::utils::{distribute_stake, RawNodeConfig, Weight};
9+
use super::utils::{RawNodeConfig, Weight, distribute_stake};
1010

1111
#[derive(Debug, Parser)]
1212
pub struct OrganicArgs {
@@ -160,7 +160,7 @@ fn nearby<R: Rng>(rng: &mut R, location: (f64, f64), dist: f64) -> (f64, f64) {
160160
mod tests {
161161
use sim_core::config::Topology;
162162

163-
use super::{organic, OrganicArgs};
163+
use super::{OrganicArgs, organic};
164164

165165
#[test]
166166
fn should_generate_valid_graph() {

sim-rs/sim-cli/src/bin/gen-test-data/strategy/random_graph.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::collections::BTreeSet;
22

3-
use anyhow::{bail, Result};
3+
use anyhow::{Result, bail};
44
use clap::Parser;
5-
use rand::{seq::IndexedRandom as _, Rng as _};
5+
use rand::{Rng as _, seq::IndexedRandom as _};
66

7-
use crate::strategy::utils::{distribute_stake, GraphBuilder, RawNodeConfig, Weight};
7+
use crate::strategy::utils::{GraphBuilder, RawNodeConfig, Weight, distribute_stake};
88

99
#[derive(Debug, Parser)]
1010
pub struct RandomGraphArgs {
@@ -100,7 +100,7 @@ fn track_connections(connected: &mut BTreeSet<usize>, graph: &GraphBuilder, from
100100
mod tests {
101101
use sim_core::config::Topology;
102102

103-
use super::{random_graph, RandomGraphArgs};
103+
use super::{RandomGraphArgs, random_graph};
104104

105105
#[test]
106106
fn should_generate_valid_graph() {

sim-rs/sim-cli/src/bin/gen-test-data/strategy/simplified.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::time::Duration;
22

33
use anyhow::Result;
44
use clap::Parser;
5-
use rand::{rngs::ThreadRng, Rng};
5+
use rand::{Rng, rngs::ThreadRng};
66

7-
use super::utils::{distribute_stake, GraphBuilder, RawNodeConfig};
7+
use super::utils::{GraphBuilder, RawNodeConfig, distribute_stake};
88

99
#[derive(Debug, Parser)]
1010
pub struct SimplifiedArgs {
@@ -129,7 +129,7 @@ pub fn simplified(args: &SimplifiedArgs) -> Result<GraphBuilder> {
129129
mod tests {
130130
use sim_core::config::Topology;
131131

132-
use super::{simplified, SimplifiedArgs};
132+
use super::{SimplifiedArgs, simplified};
133133

134134
#[test]
135135
fn should_generate_valid_graph() {

sim-rs/sim-cli/src/bin/gen-test-data/strategy/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
time::Duration,
44
};
55

6-
use netsim_core::geo::{latency_between_locations, Location};
6+
use netsim_core::geo::{Location, latency_between_locations};
77
use rand::Rng;
88
use sim_core::config::{RawLinkInfo, RawNode, RawNodeLocation, RawTopology};
99
use statrs::distribution::{Beta, ContinuousCDF as _};

sim-rs/sim-cli/src/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use async_compression::tokio::write::GzipEncoder;
66
use average::Variance;
77
use itertools::Itertools as _;
88
use liveness::LivenessMonitor;
9-
use pretty_bytes_rust::{pretty_bytes, PrettyBytesOptions};
9+
use pretty_bytes_rust::{PrettyBytesOptions, pretty_bytes};
1010
use serde::Serialize;
1111
use sim_core::{
1212
clock::Timestamp,

sim-rs/sim-cli/src/main.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use anyhow::Result;
44
use clap::Parser;
55
use events::EventMonitor;
66
use figment::{
7-
providers::{Format as _, Yaml},
87
Figment,
8+
providers::{Format as _, Yaml},
99
};
1010
use sim_core::{
1111
clock::ClockCoordinator,
@@ -19,7 +19,7 @@ use tokio::{
1919
};
2020
use tokio_util::sync::CancellationToken;
2121
use tracing::{level_filters::LevelFilter, warn};
22-
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt, EnvFilter};
22+
use tracing_subscriber::{EnvFilter, layer::SubscriberExt as _, util::SubscriberInitExt};
2323

2424
mod events;
2525

@@ -126,11 +126,14 @@ async fn main() -> Result<()> {
126126
let ctrlc_token = token.clone();
127127
ctrlc::set_handler(move || {
128128
ctrlc_token.cancel();
129-
if let Some(sink) = ctrlc_sink.take() {
130-
let _ = sink.send(());
131-
} else {
132-
warn!("force quitting");
133-
process::exit(0);
129+
match ctrlc_sink.take() {
130+
Some(sink) => {
131+
let _ = sink.send(());
132+
}
133+
_ => {
134+
warn!("force quitting");
135+
process::exit(0);
136+
}
134137
}
135138
})?;
136139

@@ -162,7 +165,7 @@ mod tests {
162165
use anyhow::Result;
163166
use std::fs;
164167

165-
use crate::{read_config, Args};
168+
use crate::{Args, read_config};
166169

167170
#[test]
168171
fn should_parse_topologies() -> Result<()> {

sim-rs/sim-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sim-core"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
rust-version = "1.88"
66

77
[dependencies]

0 commit comments

Comments
 (0)