Skip to content

Commit a36e49b

Browse files
committed
Add const on clippy suggested functions.
1 parent e24cd52 commit a36e49b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,13 @@ impl QueueFile {
365365

366366
/// Returns true if removing an element will also overwrite data with zero bytes.
367367
#[inline]
368-
pub fn overwrite_on_remove(&self) -> bool {
368+
pub const fn overwrite_on_remove(&self) -> bool {
369369
self.overwrite_on_remove
370370
}
371371

372372
/// Use [`QueueFile::overwrite_on_remove`] instead.
373373
#[deprecated]
374-
pub fn get_overwrite_on_remove(&self) -> bool {
374+
pub const fn get_overwrite_on_remove(&self) -> bool {
375375
self.overwrite_on_remove()
376376
}
377377

@@ -383,13 +383,13 @@ impl QueueFile {
383383

384384
/// Returns true if every write to file will be followed by `sync_data()` call.
385385
#[inline]
386-
pub fn sync_writes(&self) -> bool {
386+
pub const fn sync_writes(&self) -> bool {
387387
self.inner.sync_writes
388388
}
389389

390390
/// Use [`QueueFile::sync_writes`] instead.
391391
#[deprecated]
392-
pub fn get_sync_writes(&self) -> bool {
392+
pub const fn get_sync_writes(&self) -> bool {
393393
self.sync_writes()
394394
}
395395

@@ -401,13 +401,13 @@ impl QueueFile {
401401

402402
/// Returns true if skips header update upon adding enabled.
403403
#[inline]
404-
pub fn skip_write_header_on_add(&self) -> bool {
404+
pub const fn skip_write_header_on_add(&self) -> bool {
405405
self.skip_write_header_on_add
406406
}
407407

408408
/// Use [`QueueFile::skip_write_header_on_add`] instead.
409409
#[deprecated]
410-
pub fn get_skip_write_header_on_add(&self) -> bool {
410+
pub const fn get_skip_write_header_on_add(&self) -> bool {
411411
self.skip_write_header_on_add()
412412
}
413413

@@ -426,13 +426,13 @@ impl QueueFile {
426426
}
427427

428428
#[inline]
429-
pub fn cache_offset_policy(&self) -> Option<OffsetCacheKind> {
429+
pub const fn cache_offset_policy(&self) -> Option<OffsetCacheKind> {
430430
self.offset_cache_kind
431431
}
432432

433433
/// Use [`QueueFile::cache_offset_policy`] instead.
434434
#[deprecated]
435-
pub fn get_cache_offset_policy(&self) -> Option<OffsetCacheKind> {
435+
pub const fn get_cache_offset_policy(&self) -> Option<OffsetCacheKind> {
436436
self.cache_offset_policy()
437437
}
438438

@@ -447,13 +447,13 @@ impl QueueFile {
447447

448448
/// Returns true if this queue contains no entries.
449449
#[inline]
450-
pub fn is_empty(&self) -> bool {
450+
pub const fn is_empty(&self) -> bool {
451451
self.elem_cnt == 0
452452
}
453453

454454
/// Returns the number of elements in this queue.
455455
#[inline]
456-
pub fn size(&self) -> usize {
456+
pub const fn size(&self) -> usize {
457457
self.elem_cnt
458458
}
459459

@@ -724,13 +724,13 @@ impl QueueFile {
724724
/// Returns the amount of bytes used by the backed file.
725725
/// Always >= [`Self::used_bytes`].
726726
#[inline]
727-
pub fn file_len(&self) -> u64 {
727+
pub const fn file_len(&self) -> u64 {
728728
self.inner.file_len
729729
}
730730

731731
/// Returns the amount of bytes used by the queue.
732732
#[inline]
733-
pub fn used_bytes(&self) -> u64 {
733+
pub const fn used_bytes(&self) -> u64 {
734734
if self.elem_cnt == 0 {
735735
self.header_len
736736
} else if self.last.pos >= self.first.pos {
@@ -759,7 +759,7 @@ impl QueueFile {
759759
}
760760

761761
#[inline]
762-
fn remaining_bytes(&self) -> u64 {
762+
const fn remaining_bytes(&self) -> u64 {
763763
self.file_len() - self.used_bytes()
764764
}
765765

@@ -818,7 +818,7 @@ impl QueueFile {
818818

819819
/// Wraps the position if it exceeds the end of the file.
820820
#[inline]
821-
fn wrap_pos(&self, pos: u64) -> u64 {
821+
const fn wrap_pos(&self, pos: u64) -> u64 {
822822
if pos < self.file_len() { pos } else { self.header_len + pos - self.file_len() }
823823
}
824824

0 commit comments

Comments
 (0)