Skip to content

Commit c65e7b3

Browse files
committed
chore(clippy): must_use attribute
1 parent 4ecbbaa commit c65e7b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct VersionMap<T> {
5353

5454
impl<T> VersionMap<T> {
5555
/// Creates a new empty `VersionMap`.
56+
#[must_use]
5657
pub fn new() -> Self {
5758
Self {
5859
versions: BTreeMap::new(),
@@ -135,6 +136,7 @@ impl<T> VersionMap<T> {
135136
///
136137
/// // Get latest major
137138
/// assert_eq!(map.get(&Version::new(1, 0, 0)), Some(&"v1.2.1"));
139+
#[must_use]
138140
pub fn get(&self, version: &Version) -> Option<&T> {
139141
if version.build.is_empty() {
140142
let maybe_value = version_alternate(version)
@@ -172,6 +174,7 @@ impl<T> VersionMap<T> {
172174
///
173175
/// // Get latest major
174176
/// assert_eq!(map.get_version(&Version::new(1, 0, 0)), Some((&Version::new(1, 2, 1), &"v1.2.1")));
177+
#[must_use]
175178
pub fn get_version(&self, version: &Version) -> Option<(&Version, &T)> {
176179
if version.build.is_empty() {
177180
let maybe_key_value = version_alternate(version)
@@ -218,6 +221,7 @@ impl<T> VersionMap<T> {
218221
/// // Get the latest version
219222
/// assert_eq!(map.get_or_latest(None), Some(&"v1.2.0"));
220223
/// ```
224+
#[must_use]
221225
pub fn get_or_latest(&self, version: Option<&Version>) -> Option<&T> {
222226
match version {
223227
Some(v) => self.get(v),
@@ -254,6 +258,7 @@ impl<T> VersionMap<T> {
254258
/// // Get the latest version
255259
/// assert_eq!(map.get_or_latest_version(None), Some((&Version::new(1, 2, 0), &"v1.2.0")));
256260
/// ```
261+
#[must_use]
257262
pub fn get_or_latest_version(&self, version: Option<&Version>) -> Option<(&Version, &T)> {
258263
match version {
259264
Some(v) => self.get_version(v),
@@ -262,11 +267,13 @@ impl<T> VersionMap<T> {
262267
}
263268

264269
/// Returns the latest version and its associated value.
270+
#[must_use]
265271
pub fn get_latest(&self) -> Option<(&Version, &T)> {
266272
self.versions.last_key_value().map(|(k, v)| (k.borrow(), v))
267273
}
268274

269275
/// Gets a value by exact version match only, without alternate lookup.
276+
#[must_use]
270277
pub fn get_exact(&self, version: &Version) -> Option<&T> {
271278
self.versions.get(version)
272279
}

0 commit comments

Comments
 (0)