Choose names that follow established API conventions and guidelines to create a consistent, intuitive codebase: 1. For conversions or views: - Use `as_*` for cheap, reference-based conversions
Choose names that follow established API conventions and guidelines to create a consistent, intuitive codebase:
as_*
for cheap, reference-based conversions
// Prefer this
fn as_socket(&self) -> socket2::SockRef<'_> {
socket2::SockRef::from(self)
}
// Instead of
fn to_socket(&self) -> socket2::SockRef<'_>
// Prefer this
pub fn sender_strong_count(&self) -> usize
// Instead of
pub fn strong_count(&self) -> usize
// Prefer this
pub fn notify_one_last_in(&self)
// Instead of
pub fn notify_one_lifo(&self)
// Prefer this
pub async fn copy_bidirectional_with_sizes<A, B>
// Instead of
pub async fn copy_bidirectional_with_size<A, B>
Deref
// Prefer this
pub fn clone_inner(&'static self) -> T
// Instead of
pub fn clone(&'static self) -> T // Confusing with Clone trait
Even when verbosity increases, prioritize clarity and prevention of API confusion. AbortOnDropHandle
may be verbose, but it clearly communicates the type’s behavior.
Enter the URL of a public GitHub repository