You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In theory one would like to be able to implement Deref, AsRef, Borrow, IntoOwned, etc for this pair of enums (or a similar pair of structs) and e.g. also use it in a Cow. However that's not possible as Deref, AsRef, Borrow explicitly return a reference from their functions. If it was instead a "normal" type, one could implement it for the above pair and still cover the existing implementations that return references.
Is there any chance to extend this by new traits, or is there another solution?
The text was updated successfully, but these errors were encountered:
The problem still exists. I'm trapped in the same situation: having two enums, one for owned data, other for borrowed counterparts. And I can't seem to be able to benefit from the AsRef / Borrow infrastructure with those. Any ideas or workarounds?
This is my particular usecase:
/// Owned wrapper for counter value.#[derive(Clone,Debug,Ord,PartialOrd,Eq,PartialEq)]pubenumCounterValue{Dword(DWORD),Large(ULONGLONG),TextUnicode(U16CString),TextAscii(String),Zero,}/// Borrowed wrapper for counter value./// It is to the `CounterValue` as a str is to the String.#[derive(Clone,Debug,Ord,PartialOrd,Eq,PartialEq)]pubenumCounterVal<'a>{Dword(DWORD),Large(ULONGLONG),TextUnicode(&'aU16CStr),TextAscii(&'astr),Zero,}
Consider something like the following two enums
In theory one would like to be able to implement Deref, AsRef, Borrow, IntoOwned, etc for this pair of enums (or a similar pair of structs) and e.g. also use it in a Cow. However that's not possible as Deref, AsRef, Borrow explicitly return a reference from their functions. If it was instead a "normal" type, one could implement it for the above pair and still cover the existing implementations that return references.
Is there any chance to extend this by new traits, or is there another solution?
The text was updated successfully, but these errors were encountered: