Neptune-Crypto/neptune-core

style: Prefer references to `cli_args::Args`

Aberta

#532 aberto em 27 de mar. de 2025

 (0 comentário) (1 reação) (0 responsável)Rust (45 forks)auto 404
choregood first issuelow priority

Métricas do repositório

Stars
 (110 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

Some test helper setup functions take a reference to cli_args::Args and others take ownership of an object. The latter type generates more boilerplate due to excessive .clone().

The intention behind cli_args::Args is that once set, they never change. (If there is a transgression against this principle anywhere, we need to fix that.) So cloning in order to pass ownership of an object that's not going to change anyway is moot in addition to boilerplatey. Let's prefer references instead.

I do think one exception is necessary. We want one copy of the CLI arguments to live on global state. And we do not want to bother keeping track of lifetimes there. So we clone it once, when constructing global state.

Most of this task boils down to fixing function interfaces in tests and red squiggly lines that result from there.

Guia do colaborador