Some places in the library don't conform to typical Rust idioms. For example, see Request...
pub trait Request<'a> {
fn get_common_fields(&self) -> &CommonFields<'a>;
fn get_common_fields_mut(&mut self) -> &mut CommonFields<'a>;
}
...which uses get_ prefix in non-idiomatic ways.
Standard Rust Accessor Naming Conventions
field(&self) -> &T: Immutable: reference accessor (no get_ prefix)
field_mut(&mut self) -> &mut T: Mutable reference accessor.
into_field(self) -> T: Consuming getter that takes ownership.
as_field(&self) -> &T or to_field(&self) -> T: Standard type-conversion accessors.
When get IS Idiomatic
The get prefix or method name is used in Rust under limited, specific circumstances:
- Lookups: Methods that require arguments to search or retrieve an item, often returning an
Option or Result (e.g., HashMap::get(&key) or Slice::get(index)).
- Single-value wrappers: Smart pointers or concurrency primitives where obtaining the underlying value is the container's core operation (e.g.,
Cell::get() or RefCell::get_mut()).
Some places in the library don't conform to typical Rust idioms. For example, see Request...
...which uses
get_prefix in non-idiomatic ways.Standard Rust Accessor Naming Conventions
field(&self) -> &T: Immutable: reference accessor (no get_ prefix)field_mut(&mut self) -> &mut T: Mutable reference accessor.into_field(self) -> T: Consuming getter that takes ownership.as_field(&self) -> &Torto_field(&self) -> T: Standard type-conversion accessors.When get IS Idiomatic
The get prefix or method name is used in Rust under limited, specific circumstances:
OptionorResult(e.g.,HashMap::get(&key)orSlice::get(index)).Cell::get()orRefCell::get_mut()).