Module dst

Source
Expand description

Working with dynamically sized types (DSTs).

DSTs are types whose size is known at run-time instead of compile-time. The primary examples of this are slices and str. While Rust provides relatively good support for DSTs (e.g. they can be held by reference like any other type), it has some rough edges. The standard library tries to paper over these with helpful functions and trait impls, but it does not account for custom DST types. In particular, new::base introduces a large number of user-facing DSTs and needs to paper over the same rough edges for all of them.

§Coping DSTs

Because DSTs cannot be held by value, they must be handled and manipulated through an indirection (a reference or a smart pointer of some kind). Copying a DST into new container (e.g. Box) requires explicit support from that container type.

This module introduces the UnsizedCopy trait (and a derive macro) that types like str implement. Container types that can support copying DSTs implement UnsizedCopyFrom.

Traits§

UnsizedCopy
An extension of Copy to dynamically sized types.
UnsizedCopyFrom
A container type that can be copied into.

Derive Macros§

UnsizedCopy
Deriving UnsizedCopy automatically.