Skip to content

Commit

Permalink
remove Clone bound from all functions with Clone + FnMut bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Ved-s authored and Adanos020 committed Jul 3, 2024
1 parent 70c7a59 commit 28f7bb5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/dock_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl<Tab> DockState<Tab> {
/// ```
pub fn filter_tabs<F>(&self, mut predicate: F) -> DockState<Tab>
where
F: Clone + FnMut(&Tab) -> bool,
F: FnMut(&Tab) -> bool,
Tab: Clone,
{
self.filter_map_tabs(move |tab| predicate(tab).then(|| tab.clone()))
Expand All @@ -539,12 +539,12 @@ impl<Tab> DockState<Tab> {
/// let tabs: Vec<_> = dock_state.iter_all_tabs().map(|(_, tab)| tab.to_owned()).collect();
/// assert_eq!(tabs, vec!["tab1".to_string(), "tab2".to_string()]);
/// ```
pub fn retain_tabs<F>(&mut self, predicate: F)
pub fn retain_tabs<F>(&mut self, mut predicate: F)
where
F: Clone + FnMut(&mut Tab) -> bool,
F: FnMut(&mut Tab) -> bool,
{
self.surfaces.retain_mut(|surface| {
surface.retain_tabs(predicate.clone());
surface.retain_tabs(&mut predicate);
!surface.is_empty()
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/dock_state/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<Tab> Surface<Tab> {
/// Returns a new [`Surface`] while mapping the tab type.
pub fn map_tabs<F, NewTab>(&self, mut function: F) -> Surface<NewTab>
where
F: Clone + FnMut(&Tab) -> NewTab,
F: FnMut(&Tab) -> NewTab,
{
self.filter_map_tabs(move |tab| Some(function(tab)))
}
Expand All @@ -110,7 +110,7 @@ impl<Tab> Surface<Tab> {
/// it'll change to [`Surface::Empty`].
pub fn filter_tabs<F>(&self, mut predicate: F) -> Surface<Tab>
where
F: Clone + FnMut(&Tab) -> bool,
F: FnMut(&Tab) -> bool,
Tab: Clone,
{
self.filter_map_tabs(move |tab| predicate(tab).then(|| tab.clone()))
Expand All @@ -121,7 +121,7 @@ impl<Tab> Surface<Tab> {
/// it'll change to [`Surface::Empty`].
pub fn retain_tabs<F>(&mut self, predicate: F)
where
F: Clone + FnMut(&mut Tab) -> bool,
F: FnMut(&mut Tab) -> bool,
{
if let Surface::Main(tree) | Surface::Window(tree, _) = self {
tree.retain_tabs(predicate);
Expand Down
10 changes: 5 additions & 5 deletions src/dock_state/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl<Tab> Tree<Tab> {
/// Returns a new [`Tree`] while mapping the tab type.
pub fn map_tabs<F, NewTab>(&self, mut function: F) -> Tree<NewTab>
where
F: Clone + FnMut(&Tab) -> NewTab,
F: FnMut(&Tab) -> NewTab,
{
self.filter_map_tabs(move |tab| Some(function(tab)))
}
Expand All @@ -777,21 +777,21 @@ impl<Tab> Tree<Tab> {
/// Any remaining empty [`Node`]s are removed.
pub fn filter_tabs<F>(&self, mut predicate: F) -> Tree<Tab>
where
F: Clone + FnMut(&Tab) -> bool,
F: FnMut(&Tab) -> bool,
Tab: Clone,
{
self.filter_map_tabs(move |tab| predicate(tab).then(|| tab.clone()))
}

/// Removes all tabs for which `predicate` returns `false`.
/// Any remaining empty [`Node`]s are also removed.
pub fn retain_tabs<F>(&mut self, predicate: F)
pub fn retain_tabs<F>(&mut self, mut predicate: F)
where
F: Clone + FnMut(&mut Tab) -> bool,
F: FnMut(&mut Tab) -> bool,
{
let mut emptied_nodes = HashSet::default();
for (index, node) in self.nodes.iter_mut().enumerate() {
node.retain_tabs(predicate.clone());
node.retain_tabs(&mut predicate);
if node.is_empty() {
emptied_nodes.insert(NodeIndex(index));
}
Expand Down
4 changes: 2 additions & 2 deletions src/dock_state/tree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl<Tab> Node<Tab> {
/// If this [`Node`] remains empty, it will change to [`Node::Empty`].
pub fn filter_tabs<F>(&self, mut predicate: F) -> Node<Tab>
where
F: Clone + FnMut(&Tab) -> bool,
F: FnMut(&Tab) -> bool,
Tab: Clone,
{
self.filter_map_tabs(move |tab| predicate(tab).then(|| tab.clone()))
Expand All @@ -350,7 +350,7 @@ impl<Tab> Node<Tab> {
/// If this [`Node`] remains empty, it will change to [`Node::Empty`].
pub fn retain_tabs<F>(&mut self, predicate: F)
where
F: Clone + FnMut(&mut Tab) -> bool,
F: FnMut(&mut Tab) -> bool,
{
if let Node::Leaf { tabs, .. } = self {
tabs.retain_mut(predicate);
Expand Down

0 comments on commit 28f7bb5

Please sign in to comment.