Allowing Label to own it's content
Looking at https://github.com/bazelbuild/rules_rust/tree/0.5.0/util/label I'm wondering why it effectively only wraps a some owned data elsewhere. Would it make sense to allow Label to be a struct which owns a string and can comfortably parse out repository_name, package_name, and target?
cc @hlopko
Yeah, I think using a Cow should work fine here?
(I suspect Label actually owning its backing data also wouldn't be the end of the world - @hlopko can hopefully speak to that :))
Is there a problem you're trying to solve? Right now the Label doesn't own its string because it doesn't have to. I expected that the user has a string from somewhere, and they use the Label struct only for parsing. If they want to own the data, they can clone parsed &str (all fields are public). If we changed Label to own its string, then the user doesn't have the option to not own it.
So, I'd like to keep supporting the non-owning scenario. Cow sounds like a solution to supporting both scenarios, but it comes with a complexity cost, so I'd only add it if there's a scenario where cloning Label fields after parsing is a bad option.
Or, we can add OwnedLabel struct next to the existing Label, and the OwnedLabel would do the field cloning for you.
What do you think?