From 37335d3f43cc04346e4f6357c1da3d826ddbbb3c Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Thu, 7 Dec 2017 22:20:25 -0700 Subject: [PATCH 1/3] Add Drop impl for linked_list::DrainFilter --- src/liballoc/linked_list.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/liballoc/linked_list.rs b/src/liballoc/linked_list.rs index 0fe3c9724224d..3ac5a85d721a1 100644 --- a/src/liballoc/linked_list.rs +++ b/src/liballoc/linked_list.rs @@ -1071,6 +1071,15 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> } } +#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] +impl<'a, T, F> Drop for DrainFilter<'a, T, F> + where F: FnMut(&mut T) -> bool, +{ + fn drop(&mut self) { + for _ in self { } + } +} + #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] impl<'a, T: 'a + fmt::Debug, F> fmt::Debug for DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool From 00acdbd51decd75ad10815ce7bcf3323830f95d6 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Thu, 7 Dec 2017 23:52:34 -0700 Subject: [PATCH 2/3] Make drop impl stable for DrainFilter --- src/liballoc/linked_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/linked_list.rs b/src/liballoc/linked_list.rs index 3ac5a85d721a1..1eac56c904da2 100644 --- a/src/liballoc/linked_list.rs +++ b/src/liballoc/linked_list.rs @@ -1071,7 +1071,7 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> } } -#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] +#[stable(feature = "drain_filter_drop", since = "1.25.0")] impl<'a, T, F> Drop for DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool, { From cdf1d7dfc94e1bc7b103af3ae466e5271ce00113 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Sat, 9 Dec 2017 01:09:23 -0700 Subject: [PATCH 3/3] Revert "Make drop impl stable for DrainFilter" This reverts commit 00acdbd51decd75ad10815ce7bcf3323830f95d6. --- src/liballoc/linked_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/linked_list.rs b/src/liballoc/linked_list.rs index 1eac56c904da2..3ac5a85d721a1 100644 --- a/src/liballoc/linked_list.rs +++ b/src/liballoc/linked_list.rs @@ -1071,7 +1071,7 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> } } -#[stable(feature = "drain_filter_drop", since = "1.25.0")] +#[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] impl<'a, T, F> Drop for DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool, {