RS.CLIPPY.MANUAL_HASH_ONE

Manual implementations of `BuildHasher::hash_one`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_hash_one. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for cases where BuildHasher::hash_one can be used.

Why is this bad?

It is more concise to use the hash_one method.

Example

use std::hash::{BuildHasher, Hash, Hasher};
use std::collections::hash_map::RandomState;

let s = RandomState::new();
let value = vec![1, 2, 3];

let mut hasher = s.build_hasher();
value.hash(&mut hasher);
let hash = hasher.finish();

Use instead:

use std::hash::BuildHasher;
use std::collections::hash_map::RandomState;

let s = RandomState::new();
let value = vec![1, 2, 3];

let hash = s.hash_one(&value);

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)