|
5 | 5 | //! Tag
|
6 | 6 |
|
7 | 7 | use alloc::string::{String, ToString};
|
8 |
| -use alloc::sync::Arc; |
9 | 8 | use alloc::vec::Vec;
|
10 | 9 | use core::cmp::Ordering;
|
11 | 10 | use core::hash::{Hash, Hasher};
|
@@ -37,7 +36,7 @@ use crate::{ImageDimensions, PublicKey, SingleLetterTag, Timestamp, UncheckedUrl
|
37 | 36 | #[derive(Debug, Clone)]
|
38 | 37 | pub struct Tag {
|
39 | 38 | buf: Vec<String>,
|
40 |
| - standardized: Arc<OnceCell<Option<TagStandard>>>, |
| 39 | + standardized: OnceCell<Option<TagStandard>>, |
41 | 40 | }
|
42 | 41 |
|
43 | 42 | impl PartialEq for Tag {
|
@@ -71,15 +70,15 @@ impl Tag {
|
71 | 70 | fn new(buf: Vec<String>, standardized: Option<TagStandard>) -> Self {
|
72 | 71 | Self {
|
73 | 72 | buf,
|
74 |
| - standardized: Arc::new(OnceCell::from(standardized)), |
| 73 | + standardized: OnceCell::from(standardized), |
75 | 74 | }
|
76 | 75 | }
|
77 | 76 |
|
78 | 77 | #[inline]
|
79 | 78 | fn new_with_empty_cell(buf: Vec<String>) -> Self {
|
80 | 79 | Self {
|
81 | 80 | buf,
|
82 |
| - standardized: Arc::new(OnceCell::new()), |
| 81 | + standardized: OnceCell::new(), |
83 | 82 | }
|
84 | 83 | }
|
85 | 84 |
|
@@ -146,10 +145,7 @@ impl Tag {
|
146 | 145 |
|
147 | 146 | /// Consume tag and get standardized tag
|
148 | 147 | pub fn to_standardized(self) -> Option<TagStandard> {
|
149 |
| - // TODO: replace with `Arc::unwrap_or_clone(self.standardized)` when MSRV will be >= 1.76.0 |
150 |
| - let standardized: OnceCell<Option<TagStandard>> = |
151 |
| - Arc::try_unwrap(self.standardized).unwrap_or_else(|arc| (*arc).clone()); |
152 |
| - match standardized.into_inner() { |
| 148 | + match self.standardized.into_inner() { |
153 | 149 | Some(inner) => inner,
|
154 | 150 | None => TagStandard::parse(&self.buf).ok(),
|
155 | 151 | }
|
|
0 commit comments