Merge remote-tracking branch 'upstream/master' into scaling

This commit is contained in:
Dorota Czaplejewicz
2020-03-07 10:46:09 +00:00
24 changed files with 412 additions and 94 deletions

View File

@ -197,6 +197,12 @@ pub trait WarningHandler {
fn handle(&mut self, warning: &str);
}
/// Removes the first matcing item
pub fn vec_remove<T, F: FnMut(&T) -> bool>(v: &mut Vec<T>, pred: F) -> Option<T> {
let idx = v.iter().position(pred);
idx.map(|idx| v.remove(idx))
}
#[cfg(test)]
mod tests {
use super::*;