Add missing_const_for_fn clippy lint (#8498)

This commit is contained in:
Thomas Coratger
2024-05-30 11:50:03 +02:00
committed by GitHub
parent 99068198db
commit 3d3f52b2a4
255 changed files with 834 additions and 804 deletions

View File

@ -40,7 +40,7 @@ pub struct Zstd {
impl Zstd {
/// Creates new [`Zstd`].
pub fn new(use_dict: bool, max_dict_size: usize, columns: usize) -> Self {
pub const fn new(use_dict: bool, max_dict_size: usize, columns: usize) -> Self {
Self {
state: if use_dict { ZstdState::PendingDictionary } else { ZstdState::Ready },
level: 0,
@ -51,7 +51,7 @@ impl Zstd {
}
}
pub fn with_level(mut self, level: i32) -> Self {
pub const fn with_level(mut self, level: i32) -> Self {
self.level = level;
self
}
@ -321,7 +321,7 @@ pub(crate) enum ZstdDictionary<'a> {
impl<'a> ZstdDictionary<'a> {
/// Returns a reference to the expected `RawDictionary`
pub(crate) fn raw(&self) -> Option<&RawDictionary> {
pub(crate) const fn raw(&self) -> Option<&RawDictionary> {
match self {
ZstdDictionary::Raw(dict) => Some(dict),
ZstdDictionary::Loaded(_) => None,
@ -329,7 +329,7 @@ impl<'a> ZstdDictionary<'a> {
}
/// Returns a reference to the expected `DecoderDictionary`
pub(crate) fn loaded(&self) -> Option<&DecoderDictionary<'_>> {
pub(crate) const fn loaded(&self) -> Option<&DecoderDictionary<'_>> {
match self {
ZstdDictionary::Raw(_) => None,
ZstdDictionary::Loaded(dict) => Some(dict),

View File

@ -53,12 +53,12 @@ impl<'a, H: NippyJarHeader> NippyJarCursor<'a, H> {
}
/// Returns a reference to the related [`NippyJar`]
pub fn jar(&self) -> &NippyJar<H> {
pub const fn jar(&self) -> &NippyJar<H> {
self.jar
}
/// Returns current row index of the cursor
pub fn row_index(&self) -> u64 {
pub const fn row_index(&self) -> u64 {
self.row
}

View File

@ -153,7 +153,7 @@ impl NippyJar<()> {
}
/// Whether this [`NippyJar`] uses a [`InclusionFilters`] and [`Functions`].
pub fn uses_filters(&self) -> bool {
pub const fn uses_filters(&self) -> bool {
self.filter.is_some() && self.phf.is_some()
}
}
@ -207,17 +207,17 @@ impl<H: NippyJarHeader> NippyJar<H> {
}
/// Gets a reference to the user header.
pub fn user_header(&self) -> &H {
pub const fn user_header(&self) -> &H {
&self.user_header
}
/// Gets total columns in jar.
pub fn columns(&self) -> usize {
pub const fn columns(&self) -> usize {
self.columns
}
/// Gets total rows in jar.
pub fn rows(&self) -> usize {
pub const fn rows(&self) -> usize {
self.rows
}
@ -232,7 +232,7 @@ impl<H: NippyJarHeader> NippyJar<H> {
}
/// Gets a reference to the compressor.
pub fn compressor(&self) -> Option<&Compressors> {
pub const fn compressor(&self) -> Option<&Compressors> {
self.compressor.as_ref()
}
@ -543,7 +543,7 @@ impl DataReader {
}
/// Returns number of bytes that represent one offset.
pub fn offset_size(&self) -> u8 {
pub const fn offset_size(&self) -> u8 {
self.offset_size
}

View File

@ -12,7 +12,7 @@ pub struct Fmph {
}
impl Fmph {
pub fn new() -> Self {
pub const fn new() -> Self {
Self { function: None }
}
}

View File

@ -12,7 +12,7 @@ pub struct GoFmph {
}
impl GoFmph {
pub fn new() -> Self {
pub const fn new() -> Self {
Self { function: None }
}
}

View File

@ -71,7 +71,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
}
/// Returns a reference to `H` of [`NippyJar`]
pub fn user_header(&self) -> &H {
pub const fn user_header(&self) -> &H {
&self.jar.user_header
}
@ -81,7 +81,7 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
}
/// Gets total writer rows in jar.
pub fn rows(&self) -> usize {
pub const fn rows(&self) -> usize {
self.jar.rows()
}
@ -451,12 +451,12 @@ impl<H: NippyJarHeader> NippyJarWriter<H> {
}
#[cfg(test)]
pub fn max_row_size(&self) -> usize {
pub const fn max_row_size(&self) -> usize {
self.jar.max_row_size
}
#[cfg(test)]
pub fn column(&self) -> usize {
pub const fn column(&self) -> usize {
self.column
}