Skip to content

Commit e3f16b5

Browse files
mplanchardmasklinn
authored andcommitted
Derive Clone for Value and ValueRef
Not having `Clone` on `Value` makes it very difficult to store extracted values in a cache, and there seems to be no reason I can see to not implement `Clone` on `ValueRef` as well, since there are legitimate use-cases for it and it is impossible for downstream consumers to implement Clone themselves.
1 parent 44869b0 commit e3f16b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ua-parser/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub mod user_agent {
253253
/// Borrowed extracted value, borrows the content of the original
254254
/// parser or the content of the user agent string, unless a
255255
/// replacement is performed. (which is only possible for the )
256-
#[derive(PartialEq, Eq, Default, Debug)]
256+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
257257
pub struct ValueRef<'a> {
258258
///
259259
pub family: Cow<'a, str>,
@@ -284,7 +284,7 @@ pub mod user_agent {
284284

285285
/// Owned extracted value, identical to [`ValueRef`] but not
286286
/// linked to either the UA string or the extractor.
287-
#[derive(PartialEq, Eq, Default, Debug)]
287+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
288288
pub struct Value {
289289
///
290290
pub family: String,
@@ -417,7 +417,7 @@ pub mod os {
417417
}
418418

419419
/// An OS extraction result.
420-
#[derive(PartialEq, Eq, Default, Debug)]
420+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
421421
pub struct ValueRef<'a> {
422422
///
423423
pub os: Cow<'a, str>,
@@ -447,7 +447,7 @@ pub mod os {
447447
}
448448

449449
/// Owned version of [`ValueRef`].
450-
#[derive(PartialEq, Eq, Default, Debug)]
450+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
451451
pub struct Value {
452452
///
453453
pub os: String,
@@ -581,7 +581,7 @@ pub mod device {
581581

582582
/// Extracted device content, may borrow from one of the
583583
/// [`Parser`] or from the user agent string.
584-
#[derive(PartialEq, Eq, Default, Debug)]
584+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
585585
pub struct ValueRef<'a> {
586586
///
587587
pub device: Cow<'a, str>,
@@ -606,7 +606,7 @@ pub mod device {
606606
}
607607

608608
/// Owned version of [`ValueRef`].
609-
#[derive(PartialEq, Eq, Default, Debug)]
609+
#[derive(PartialEq, Eq, Default, Debug, Clone)]
610610
pub struct Value {
611611
///
612612
pub device: String,

0 commit comments

Comments
 (0)