Skip to content

Commit 188257d

Browse files
Migrate to 1.95 rust
1 parent 10316a0 commit 188257d

18 files changed

Lines changed: 24 additions & 32 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.92-alpine AS builder
1+
FROM rust:1.95-alpine AS builder
22

33
LABEL maintainer="Ilya Builuk <ilya.builuk@gmail.com>" \
44
org.opencontainers.image.title="A Vehicle Routing Problem solver CLI" \

experiments/heuristic-research/src/solver/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl HyperHeuristicState {
170170
);
171171
search_states
172172
.values_mut()
173-
.for_each(|states| states.sort_by(|SearchResult(a, ..), SearchResult(b, ..)| a.cmp(b)));
173+
.for_each(|states| states.sort_by_key(|SearchResult(a, ..)| *a));
174174

175175
let mut heuristic_states =
176176
data.lines().skip_while(|line| *line != "heuristic:").skip(2).take_while(|line| !line.is_empty()).fold(
@@ -200,7 +200,7 @@ impl HyperHeuristicState {
200200
);
201201
heuristic_states
202202
.values_mut()
203-
.for_each(|states| states.sort_by(|HeuristicResult(_, a, ..), HeuristicResult(_, b, ..)| a.cmp(b)));
203+
.for_each(|states| states.sort_by_key(|HeuristicResult(_, a, ..)| *a));
204204

205205
Some(Self { names, states, search_states, heuristic_states })
206206
} else {

rosomaxa/src/termination/min_variation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292

9393
result
9494
});
95-
values.sort_unstable_by(|(a, _), (b, _)| a.cmp(b));
95+
values.sort_unstable_by_key(|(a, _)| *a);
9696
}
9797

9898
if *period > elapsed_time || values.len() < 2 {

rosomaxa/tests/unit/utils/iterators_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ mod sampling_search {
163163
})
164164
.collect::<Vec<_>>();
165165

166-
results.sort_by(|(a, _), (b, _)| a.cmp(b));
166+
results.sort_by_key(|(a, _)| *a);
167167
let median = results[results.len() / 2];
168168
assert!(median.0 < 250);
169169
assert!(results.iter().all(|(_, count)| *count < 100));

vrp-cli/src/extensions/generate/plan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ fn get_location_fn(
9797
};
9898
Ok(Box::new(move |rnd| {
9999
// TODO allow to configure distribution
100-
let lat = rnd.uniform_real((bounding_box.0).0 as Float, (bounding_box.1).0 as Float) as f64;
101-
let lng = rnd.uniform_real((bounding_box.0).1 as Float, (bounding_box.1).1 as Float) as f64;
100+
let lat = rnd.uniform_real((bounding_box.0).0 as Float, (bounding_box.1).0 as Float);
101+
let lng = rnd.uniform_real((bounding_box.0).1 as Float, (bounding_box.1).1 as Float);
102102

103103
Location::Coordinate { lat, lng }
104104
}))

vrp-core/src/algorithms/clustering/dbscan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
if other_neighbours.len() >= min_points {
5050
neighbors
5151
.extend(other_neighbours.iter().filter(|&point| !neighbors_index.contains(point)).cloned());
52-
neighbors_index.extend(other_neighbours.into_iter());
52+
neighbors_index.extend(other_neighbours);
5353
}
5454
}
5555

vrp-core/src/models/problem/costs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<T: TransportFallback> TimeAgnosticMatrixTransportCost<T> {
239239
/// Creates an instance of `TimeAgnosticMatrixTransportCost`.
240240
pub fn new(costs: Vec<MatrixData>, size: usize, fallback: T) -> Result<Self, GenericError> {
241241
let mut costs = costs;
242-
costs.sort_by(|a, b| a.index.cmp(&b.index));
242+
costs.sort_by_key(|a| a.index);
243243

244244
if costs.iter().any(|costs| costs.timestamp.is_some()) {
245245
return Err("time aware routing".into());
@@ -316,7 +316,7 @@ impl<T: TransportFallback> TimeAwareMatrixTransportCost<T> {
316316
let costs = costs
317317
.into_iter()
318318
.map(|(profile, mut matrices)| {
319-
matrices.sort_by(|a, b| (a.timestamp.unwrap() as u64).cmp(&(b.timestamp.unwrap() as u64)));
319+
matrices.sort_by_key(|a| a.timestamp.unwrap() as u64);
320320
let timestamps = matrices.iter().map(|matrix| matrix.timestamp.unwrap() as u64).collect();
321321

322322
(profile, (timestamps, matrices))

vrp-core/src/models/problem/fleet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Fleet {
161161

162162
let profiles: HashMap<usize, Profile> = vehicles.iter().map(|v| (v.profile.index, v.profile.clone())).collect();
163163
let mut profiles = profiles.into_iter().collect::<Vec<_>>();
164-
profiles.sort_by(|(a, _), (b, _)| a.cmp(b));
164+
profiles.sort_by_key(|(a, _)| *a);
165165
let (_, profiles): (Vec<_>, Vec<_>) = profiles.into_iter().unzip();
166166

167167
let actors = vehicles

vrp-core/src/models/solution/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ impl Registry {
4646

4747
/// Returns list of all available actors.
4848
pub fn available(&'_ self) -> impl Iterator<Item = Arc<Actor>> + '_ {
49-
self.available.iter().flat_map(|(_, set)| set.iter().cloned())
49+
self.available.values().flat_map(|set| set.iter().cloned())
5050
}
5151

5252
/// Returns next available actors from each different type.
5353
pub fn next(&'_ self) -> impl Iterator<Item = Arc<Actor>> + '_ {
54-
self.available.iter().flat_map(move |(_, set)| {
54+
self.available.values().flat_map(|set| {
5555
// NOTE pick a random actor from set of available actors.
5656
let skip_amount = if set.len() < 2 { 0 } else { self.random.uniform_int(0, set.len() as i32 - 1) as usize };
5757
set.iter().skip(skip_amount).take(1).cloned()

vrp-core/src/models/solution/route.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Activity {
123123

124124
/// Checks whether activity job has a parent multi job.
125125
pub fn has_parent_job(&self) -> bool {
126-
self.job.as_ref().map_or(false, |single| Multi::is_child(single))
126+
self.job.as_ref().is_some_and(|single| Multi::is_child(single))
127127
}
128128

129129
/// Returns job if activity has it.

0 commit comments

Comments
 (0)