Working map shift gen
This commit is contained in:
@@ -22,3 +22,35 @@ pub fn find_mapping(
|
||||
.filter(|(rust, _)| rust <= target)
|
||||
.max_by_key(|(rust, _)| *rust)
|
||||
}
|
||||
|
||||
impl RustMap {
|
||||
pub fn shifted(self, lines: isize, cols: isize) -> Self {
|
||||
Self(
|
||||
self.0.saturating_add_signed(lines),
|
||||
self.1.saturating_add_signed(cols),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl MistMap {
|
||||
pub fn shifted(self, lines: isize, cols: isize) -> Self {
|
||||
Self(
|
||||
self.0.saturating_add_signed(lines),
|
||||
self.1.saturating_add_signed(cols),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shift_rust_mappings(mappings: &mut HashSet<(RustMap, MistMap)>, lines: isize, cols: isize) {
|
||||
*mappings = mappings
|
||||
.iter()
|
||||
.map(|(rust, mist)| (rust.shifted(lines, cols), *mist))
|
||||
.collect();
|
||||
}
|
||||
|
||||
pub fn shift_mist_mappings(mappings: &mut HashSet<(RustMap, MistMap)>, lines: isize, cols: isize) {
|
||||
*mappings = mappings
|
||||
.iter()
|
||||
.map(|(rust, mist)| (*rust, mist.shifted(lines, cols)))
|
||||
.collect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user