Skip to content

Commit

Permalink
Remove Clone implementation for MatchedText.
Browse files Browse the repository at this point in the history
`MatchedText` cannot properly implement this trait. Even when it has a
`'static` lifetime, it may still borrow data, and this means that the
clone may copy out of a borrow and so fundementally differ from its
source.
  • Loading branch information
olson-sean-k committed Nov 10, 2023
1 parent fb8a995 commit b119af9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ impl<'t> MatchedText<'t> {
/// Clones any borrowed data to an owning instance.
///
/// This function is similar to [`into_owned`], but does not consume its receiver. Due to a
/// technical limitation, `MatchedText` cannot properly implement [`Clone`] with borrowed data
/// , so this function is provided as a stop gap that allows a distinct instance to be created
/// that owns its data.
/// technical limitation, `MatchedText` cannot properly implement [`Clone`], so this function
/// is provided as a stop gap that allows a distinct instance to be created that owns its data.
///
/// [`Clone`]: std::clone::Clone
/// [`into_owned`]: crate::MatchedText::into_owned
Expand Down Expand Up @@ -176,14 +175,6 @@ impl<'t> MatchedText<'t> {
}
}

impl Clone for MatchedText<'static> {
fn clone(&self) -> Self {
MatchedText {
inner: self.inner.to_owned(),
}
}
}

// TODO: This probably shouldn't be part of the public API.
impl<'t> From<BorrowedText<'t>> for MatchedText<'t> {
fn from(captures: BorrowedText<'t>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/walk/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl FilterAny {
/// Describes a file matching a [`Glob`] in a directory tree.
///
/// [`Glob`]: crate::Glob
#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct GlobEntry {
entry: TreeEntry,
matched: MatchedText<'static>,
Expand Down

0 comments on commit b119af9

Please sign in to comment.