[core] Implement `Cow<'a, PackageIdent>` for `PackageIdent`.
This change will be used in the install logic in common to better
express fully qualified package identifiers by type.
// See the License for the specific language governing permissions and
// limitations under the License.
+use std::borrow::Cow;
use std::cmp::{Ordering, PartialOrd};
use std::fmt;
use std::result;
@@ -274,6 +275,18 @@ impl Ord for PackageIdent {
}
}
+impl<'a> From<PackageIdent> for Cow<'a, PackageIdent> {
+ fn from(pi: PackageIdent) -> Cow<'a, PackageIdent> {
+ Cow::Owned(pi)
+ }
+}
+
+impl<'a> From<&'a PackageIdent> for Cow<'a, PackageIdent> {
+ fn from(pi: &'a PackageIdent) -> Cow<'a, PackageIdent> {
+ Cow::Borrowed(pi)
+ }
+}
+
/// Sorts two packages according to their version.
///
/// We are a bit more strict than your average package management solution on versioning.
