Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring Text to be Clone #72

Open
yrashk opened this issue Jul 20, 2023 · 0 comments
Open

Requiring Text to be Clone #72

yrashk opened this issue Jul 20, 2023 · 0 comments

Comments

@yrashk
Copy link

yrashk commented Jul 20, 2023

I have a case where to clone structures like Field, I need to have an additional constraint for T to be Clone, which quickly proliferates through the codebase when T is kept generic.

Is there any specific reason for the Text trait not requiring Clone from the get-go? For the implementations defined in the project, it works just fine:

diff --git a/src/common.rs b/src/common.rs
index c5189fa..f44b5b2 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -11,7 +11,7 @@ use crate::position::Pos;
 
 /// Text abstracts over types that hold a string value.
 /// It is used to make the AST generic over the string type.
-pub trait Text<'a>: 'a {
+pub trait Text<'a>: 'a + Clone {
     type Value: 'a + From<&'a str> + AsRef<str> + std::borrow::Borrow<str> + PartialEq + Eq + PartialOrd + Ord + fmt::Debug + Clone; 
 }

Is there an anticipation that somebody will use an implementation of Text that is not cloneable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant