where T: Clone {
/// Returns `Some` item which is the first that `f` returns `true` with a reference to it
/// as a parameter or `None` if no such item exists in the queue.
- fn clone_used_if(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool {
+ fn clone_used_if(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool, T: Clone {
self.in_use.iter().find(|r| predicate(r)).cloned()
}
/// Fork-function for `take_used_if` and `clone_used_if`.
- pub fn get_used_if(&mut self, action: GetAction, predicate: P) -> Option where P: Fn(&T) -> bool {
+ pub fn get_used_if(&mut self, action: GetAction, predicate: P) -> Option where P: Fn(&T) -> bool, T: Clone {
match action {
GetAction::Take => self.take_used_if(predicate),
GetAction::Clone => self.clone_used_if(predicate),
@@ -104,7 +104,7 @@ impl UsingQueue where T: Clone {
/// a parameter, otherwise `None`.
/// Will not destroy a block if a reference to it has previously been returned by `use_last_ref`,
/// but rather clone it.
- pub fn pop_if(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool {
+ pub fn pop_if(&mut self, predicate: P) -> Option where P: Fn(&T) -> bool, T: Clone {
// a bit clumsy - TODO: think about a nicer way of expressing this.
if let Some(x) = self.pending.take() {
if predicate(&x) {