List of all the std traits?

Hi,
Is there an exhaustive list of all the traits the std (and only the std) has?
Of course, I can dive in the source or doc.rs and find out.

But I am after an up to date and exhaustive list.

Is there any existing resource for this?

Thanks guys and happy new year :slightly_smiling_face:

https://doc.rust-lang.org/std/all.html#traits

6 Likes

:grinning:
I am so happy,

Thanks a lot

1 Like

Hmm… I don't love that list, as it includes lots of unstable, or OS-specific stuff, too.

Here's my attempt of filtering and re-formatting this into a list of stable, cross-platform, non-deprecated traits:

(not proof-read, I used some copy-paste, Rustdoc, and regexes)

alloc::GlobalAlloc A memory allocator that can be registered as the standard library’s default through the #[global_allocator] attribute.
any::Any A trait to emulate dynamic typing.
borrow::Borrow A trait for borrowing data.
borrow::BorrowMut A trait for mutably borrowing data.
borrow::ToOwned A generalization of Clone to borrowed data.
clone::Clone A common trait for the ability to explicitly duplicate an object.
cmp::Eq Trait for comparisons corresponding to equivalence relations.
cmp::Ord Trait for types that form a total order.
cmp::PartialEq Trait for comparisons using the equality operator.
cmp::PartialOrd Trait for types that form a partial order.
convert::AsMut Used to do a cheap mutable-to-mutable reference conversion.
convert::AsRef Used to do a cheap reference-to-reference conversion.
convert::From Used to do value-to-value conversions while consuming the input value. It is the reciprocal of Into.
convert::Into A value-to-value conversion that consumes the input value. The opposite of From.
convert::TryFrom Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of TryInto.
convert::TryInto An attempted conversion that consumes self, which may or may not be expensive.
default::Default A trait for giving a type a useful default value.
error::Error Error is a trait representing the basic expectations for error values, i.e., values of type E in Result<T, E>.
fmt::Binary b formatting.
fmt::Debug ? formatting.
fmt::Display Format trait for an empty format, {}.
fmt::LowerExp e formatting.
fmt::LowerHex x formatting.
fmt::Octal o formatting.
fmt::Pointer p formatting.
fmt::UpperExp E formatting.
fmt::UpperHex X formatting.
fmt::Write A trait for writing or formatting into Unicode-accepting buffers or streams.
future::Future A future represents an asynchronous computation obtained by use of async.
future::IntoFuture Conversion into a Future.
hash::BuildHasher A trait for creating instances of Hasher.
hash::Hash A hashable type.
hash::Hasher A trait for hashing an arbitrary stream of bytes.
io::BufRead A BufRead is a type of Reader which has an internal buffer, allowing it to perform extra ways of reading.
io::IsTerminal Trait to determine if a descriptor/handle refers to a terminal/tty.
io::Read The Read trait allows for reading bytes from a source.
io::Seek The Seek trait provides a cursor which can be moved within a stream of bytes.
io::Write A trait for objects which are byte-oriented sinks.
iter::DoubleEndedIterator An iterator able to yield elements from both ends.
iter::ExactSizeIterator An iterator that knows its exact length.
iter::Extend Extend a collection with the contents of an iterator.
iter::FromIterator Conversion from an Iterator.
iter::FusedIterator An iterator that always continues to yield None when exhausted.
iter::IntoIterator Conversion into an Iterator.
iter::Iterator A trait for dealing with iterators.
iter::Product Trait to represent types that can be created by multiplying elements of an iterator.
iter::Sum Trait to represent types that can be created by summing up an iterator.
marker::Copy Types whose values can be duplicated simply by copying bits.
marker::Send Types that can be transferred across thread boundaries.
marker::Sized Types with a constant size known at compile time.
marker::Sync Types for which it is safe to share references between threads.
marker::Unpin Types that do not require any pinning guarantees.
net::ToSocketAddrs A trait for objects which can be converted or resolved to one or more SocketAddr values.
ops::Add The addition operator +.
ops::AddAssign The addition assignment operator +=.
ops::BitAnd The bitwise AND operator &.
ops::BitAndAssign The bitwise AND assignment operator &=.
ops::BitOr The bitwise OR operator |.
ops::BitOrAssign The bitwise OR assignment operator |=.
ops::BitXor The bitwise XOR operator ^.
ops::BitXorAssign The bitwise XOR assignment operator ^=.
ops::Deref Used for immutable dereferencing operations, like *v.
ops::DerefMut Used for mutable dereferencing operations, like in *v = 1;.
ops::Div The division operator /.
ops::DivAssign The division assignment operator /=.
ops::Drop Custom code within the destructor.
ops::Fn The version of the call operator that takes an immutable receiver.
ops::FnMut The version of the call operator that takes a mutable receiver.
ops::FnOnce The version of the call operator that takes a by-value receiver.
ops::Index Used for indexing operations (container[index]) in immutable contexts.
ops::IndexMut Used for indexing operations (container[index]) in mutable contexts.
ops::Mul The multiplication operator *.
ops::MulAssign The multiplication assignment operator *=.
ops::Neg The unary negation operator -.
ops::Not The unary logical negation operator !.
ops::RangeBounds RangeBounds is implemented by Rust’s built-in range types, produced by range syntax like .., a.., ..b, ..=c, d..e, or f..=g.
ops::Rem The remainder operator %.
ops::RemAssign The remainder assignment operator %=.
ops::Shl The left shift operator <<. Note that because this trait is implemented for all integer types with multiple right-hand-side types, Rust’s type checker has special handling for _ << _, setting the result type for integer operations to the type of the left-hand-side operand. This means that though a << b and a.shl(b) are one and the same from an evaluation standpoint, they are different when it comes to type inference.
ops::ShlAssign The left shift assignment operator <<=.
ops::Shr The right shift operator >>. Note that because this trait is implemented for all integer types with multiple right-hand-side types, Rust’s type checker has special handling for _ >> _, setting the result type for integer operations to the type of the left-hand-side operand. This means that though a >> b and a.shr(b) are one and the same from an evaluation standpoint, they are different when it comes to type inference.
ops::ShrAssign The right shift assignment operator >>=.
ops::Sub The subtraction operator -.
ops::SubAssign The subtraction assignment operator -=.
os::fd::AsFd A trait to borrow the file descriptor from an underlying object.
os::fd::AsRawFd A trait to extract the raw file descriptor from an underlying object.
os::fd::FromRawFd A trait to express the ability to construct an object from a raw file descriptor.
os::fd::IntoRawFd A trait to express the ability to consume an object and acquire ownership of its raw file descriptor.
panic::RefUnwindSafe A marker trait representing types where a shared reference is considered unwind safe.
panic::UnwindSafe A marker trait which represents “panic safe” types in Rust.
process::Termination A trait for implementing arbitrary return types in the main function.
slice::SliceIndex A helper trait used for indexing operations.
str::FromStr Parse a value from a string
string::ToString A trait for converting a value to a String.
task::Wake The implementation of waking a task on an executor.
12 Likes

Wow that's great!
If it's the safest, I will use it.

Thanks :+1: