Merge branch 'refactor/must-use-self' into 'main'

address clippy's latest lint

See merge request tpo/core/arti!205
This commit is contained in:
eta 2021-12-20 18:38:18 +00:00
commit 0cdf65c256
6 changed files with 10 additions and 0 deletions

View File

@ -313,6 +313,7 @@ impl<R: Runtime> TorClient<R> {
/// Calling this function is usually preferable to creating a
/// completely separate TorClient instance, since it can share its
/// internals with the existing `TorClient`.
#[must_use]
pub fn isolated_client(&self) -> TorClient<R> {
let mut result = self.clone();
result.client_isolation = IsolationToken::new();

View File

@ -67,12 +67,14 @@ impl<T> TimerangeBound<T> {
/// Adjust this time-range bound to tolerate an expiration time farther
/// in the future.
#[must_use]
pub fn extend_tolerance(self, d: time::Duration) -> Self {
let end = self.end.map(|t| t + d);
Self { end, ..self }
}
/// Adjust this time-range bound to tolerate an initial validity
/// time farther in the past.
#[must_use]
pub fn extend_pre_tolerance(self, d: time::Duration) -> Self {
let start = self.start.map(|t| t - d);
Self { start, ..self }

View File

@ -40,6 +40,7 @@ impl From<derive_builder::UninitializedFieldError> for ConfigBuildError {
impl ConfigBuildError {
/// Return a new ConfigBuildError that prefixes its field name with
/// `prefix` and a dot.
#[must_use]
pub fn within(&self, prefix: &str) -> Self {
use ConfigBuildError::*;
match self {

View File

@ -1386,6 +1386,7 @@ impl<RS> UnvalidatedConsensus<RS> {
/// Tell the unvalidated consensus how many authorities we believe in.
///
/// Without knowing this number, we can't validate the signature.
#[must_use]
pub fn set_n_authorities(self, n_authorities: u16) -> Self {
UnvalidatedConsensus {
n_authorities: Some(n_authorities),

View File

@ -116,6 +116,7 @@ impl Pos {
///
/// TODO: I wish I knew an efficient safe way to do this that
/// guaranteed that we we always talking about the right string.
#[must_use]
pub fn within(self, s: &str) -> Self {
match self {
Pos::Byte { off } => Self::from_offset(s, off),
@ -358,6 +359,7 @@ impl Error {
/// Return a new error based on this one, with any byte-based
/// position mapped to some line within a string.
#[must_use]
pub fn within(mut self, s: &str) -> Error {
if let Some(p) = self.pos_mut() {
*p = p.within(s);
@ -367,6 +369,7 @@ impl Error {
/// Return a new error based on this one, with the position (if
/// any) replaced by 'p'.
#[must_use]
pub fn at_pos(mut self, p: Pos) -> Error {
if let Some(mypos) = self.pos_mut() {
*mypos = p;
@ -376,6 +379,7 @@ impl Error {
/// Return a new error based on this one, with the position (if
/// replaced by 'p' if it had no position before.
#[must_use]
pub fn or_at_pos(mut self, p: Pos) -> Error {
if let Some(mypos) = self.pos_mut() {
if *mypos == Pos::None {

View File

@ -64,6 +64,7 @@ impl TestingStateMgr {
/// Create a new unlocked [`TestingStateMgr`] that shares the same
/// underlying storage with this one.
#[must_use]
pub fn new_manager(&self) -> Self {
let inner = self.inner.lock().expect("Lock poisoned.");
let new_inner = TestingStateMgrInner {