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

@@ -196,7 +196,7 @@ impl NetworkArgs {
/// Sets the p2p port to zero, to allow the OS to assign a random unused port when
/// the network components bind to a socket.
pub fn with_unused_p2p_port(mut self) -> Self {
pub const fn with_unused_p2p_port(mut self) -> Self {
self.port = 0;
self
}
@@ -324,7 +324,7 @@ impl DiscoveryArgs {
/// Set the discovery port to zero, to allow the OS to assign a random unused port when
/// discovery binds to the socket.
pub fn with_unused_discovery_port(mut self) -> Self {
pub const fn with_unused_discovery_port(mut self) -> Self {
self.port = 0;
self
}

View File

@@ -177,19 +177,19 @@ pub struct RpcServerArgs {
impl RpcServerArgs {
/// Enables the HTTP-RPC server.
pub fn with_http(mut self) -> Self {
pub const fn with_http(mut self) -> Self {
self.http = true;
self
}
/// Enables the WS-RPC server.
pub fn with_ws(mut self) -> Self {
pub const fn with_ws(mut self) -> Self {
self.ws = true;
self
}
/// Enables the Auth IPC
pub fn with_auth_ipc(mut self) -> Self {
pub const fn with_auth_ipc(mut self) -> Self {
self.auth_ipc = true;
self
}
@@ -225,21 +225,21 @@ impl RpcServerArgs {
/// Set the http port to zero, to allow the OS to assign a random unused port when the rpc
/// server binds to a socket.
pub fn with_http_unused_port(mut self) -> Self {
pub const fn with_http_unused_port(mut self) -> Self {
self.http_port = 0;
self
}
/// Set the ws port to zero, to allow the OS to assign a random unused port when the rpc
/// server binds to a socket.
pub fn with_ws_unused_port(mut self) -> Self {
pub const fn with_ws_unused_port(mut self) -> Self {
self.ws_port = 0;
self
}
/// Set the auth port to zero, to allow the OS to assign a random unused port when the rpc
/// server binds to a socket.
pub fn with_auth_unused_port(mut self) -> Self {
pub const fn with_auth_unused_port(mut self) -> Self {
self.auth_port = 0;
self
}

View File

@@ -194,7 +194,7 @@ impl<D: XdgPath> MaybePlatformPath<D> {
}
/// Returns true if a custom path is set
pub fn is_some(&self) -> bool {
pub const fn is_some(&self) -> bool {
self.0.is_some()
}
@@ -265,7 +265,7 @@ pub struct ChainPath<D>(PlatformPath<D>, Chain);
impl<D> ChainPath<D> {
/// Returns a new `ChainPath` given a `PlatformPath` and a `Chain`.
pub fn new(path: PlatformPath<D>, chain: Chain) -> Self {
pub const fn new(path: PlatformPath<D>, chain: Chain) -> Self {
Self(path, chain)
}

View File

@@ -49,7 +49,7 @@ impl EngineMessageStore {
/// Creates a new [EngineMessageStore] at the given path.
///
/// The path is expected to be a directory, where individual message JSON files will be stored.
pub fn new(path: PathBuf) -> Self {
pub const fn new(path: PathBuf) -> Self {
Self { path }
}

View File

@@ -22,7 +22,7 @@ pub struct EngineSkipFcu<S> {
impl<S> EngineSkipFcu<S> {
/// Creates new [EngineSkipFcu] stream wrapper.
pub fn new(stream: S, threshold: usize) -> Self {
pub const fn new(stream: S, threshold: usize) -> Self {
Self {
stream,
threshold,

View File

@@ -23,7 +23,7 @@ pub struct EngineSkipNewPayload<S> {
impl<S> EngineSkipNewPayload<S> {
/// Creates new [EngineSkipNewPayload] stream wrapper.
pub fn new(stream: S, threshold: usize) -> Self {
pub const fn new(stream: S, threshold: usize) -> Self {
Self { stream, threshold, skipped: 0 }
}
}

View File

@@ -279,10 +279,10 @@ fn describe_io_stats() {
}
#[cfg(not(target_os = "linux"))]
fn collect_io_stats() {}
const fn collect_io_stats() {}
#[cfg(not(target_os = "linux"))]
fn describe_io_stats() {}
const fn describe_io_stats() {}
#[cfg(test)]
mod tests {

View File

@@ -177,13 +177,13 @@ impl NodeConfig {
}
/// Set the metrics address for the node
pub fn with_metrics(mut self, metrics: SocketAddr) -> Self {
pub const fn with_metrics(mut self, metrics: SocketAddr) -> Self {
self.metrics = Some(metrics);
self
}
/// Set the instance for the node
pub fn with_instance(mut self, instance: u16) -> Self {
pub const fn with_instance(mut self, instance: u16) -> Self {
self.instance = instance;
self
}
@@ -219,19 +219,19 @@ impl NodeConfig {
}
/// Set the database args for the node
pub fn with_db(mut self, db: DatabaseArgs) -> Self {
pub const fn with_db(mut self, db: DatabaseArgs) -> Self {
self.db = db;
self
}
/// Set the dev args for the node
pub fn with_dev(mut self, dev: DevArgs) -> Self {
pub const fn with_dev(mut self, dev: DevArgs) -> Self {
self.dev = dev;
self
}
/// Set the pruning args for the node
pub fn with_pruning(mut self, pruning: PruningArgs) -> Self {
pub const fn with_pruning(mut self, pruning: PruningArgs) -> Self {
self.pruning = pruning;
self
}