Previously there were lifetime issue because the key needed the same lifetime as the underlying parsed file, which was hard to accomplish even with `&'static str'` as it really needed "&'static &'static str". However, this also means that owned keys can't be passed anymore.
Unified · Split
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | use bstr::{BStr, ByteSlice}; |
| 2 | 2 | |
| 3 | 3 | /// Parse parts of a Git configuration key, like `remote.origin.url` or `core.bare`. |
| 4 | −pub trait AsKey { | |
| 4 | +pub trait AsKey: Copy { | |
| 5 | 5 | /// Return a parsed key reference, containing all relevant parts of a key. |
| 6 | 6 | /// For instance, `remote.origin.url` such key would yield access to `("remote", Some("origin"), "url")` |
| 7 | 7 | /// while `user.name` would yield `("user", None, "name")`. |
| @@ -22,7 +22,7 @@ mod impls { · 14 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | use crate::key::{AsKey, KeyRef}; |
| 24 | 24 | |
| 25 | − impl AsKey for String { | |
| 25 | + impl AsKey for &String { | |
| 26 | 26 | fn as_key(&self) -> KeyRef<'_> { |
| 27 | 27 | self.try_as_key() |
| 28 | 28 | .unwrap_or_else(|| panic!("'{self}' is not a valid configuration key")) |
| @@ -44,7 +44,7 @@ mod impls { · 15 unmodified lines | ||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | − impl AsKey for BString { | |
| 47 | + impl AsKey for &BString { | |
| 48 | 48 | fn as_key(&self) -> KeyRef<'_> { |
| 49 | 49 | self.try_as_key() |
| 50 | 50 | .unwrap_or_else(|| panic!("'{self}' is not a valid configuration key")) |