Closed
Description
Simple example:
use std::cmp::Ordering;
fn something<T,F>(slice: &mut [T], mut compare: F) where
F: FnMut(&T,&T) -> Ordering
{
// This compiles fine:
if compare(&slice[0], &slice[1]) == Ordering::Less {
slice.swap(0, 1);
}
// But this does not:
let mut cmp = |a,b| compare(a,b) == Ordering::Less;
if cmp(&slice[0], &slice[1]) {
slice.swap(0, 1);
}
}
Playpen: http://is.gd/niaLAa
It seems like it marks the closure return value as a borrowed value from slice
, even though it is just a bool.