Skip to content
Branch: dyn-type
Find file History
Pull request Compare This branch is 4 commits ahead, 831 commits behind rust-lang:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.vscode
10-Motivation.md
20-Tutorial.md
21-Examples.md
30-Changes.md
31-Custom-DST-from-scratch.md
40-Drawbacks.md
50-Rationales.md
51-Alternatives.md
52-Extensions.md
53-Bikeshed.md
README.md

README.md

  • Feature Name: dyn_type
  • Start Date: 2018-01-04
  • RFC PR: (leave this empty)
  • Rust Issue: (leave this empty)

Summary

Generalize the concept of Dynamic Sized Types (DSTs) and enable custom DSTs.

Motivation

This RFC is a replacement of RFC #1524. The main motivations of custom DSTs are:

  • DST allows us to get rid of combinatorial explosion when interacting with smart pointers. Instead of defining BoxMatrix, RcMatrix, GcMatrix etc, we get Box<Matrix>, Rc<Matrix>, Gc<Matrix> from a single type.

  • The Index and Deref trait requires us to return a reference without allocation, i.e. indexing operation can’t return a MatrixRef<'a> even if this is the only solution without custom DST.

  • Allow more possibilities for modifying existing APIs involving DST types without breakage.

We expect many types will benefit from custom DSTs, here are some examples:

  • Multi-dimensional arrays (matrix and tensor libraries).
  • Length-prefixed structures e.g. Pascal strings or C structures with a flexible array member.
  • CStr.
  • Multi-encoded string.
  • Bit array.

Guide-level explanation

Reference-level explanation

Drawbacks

Rationale and alternatives

Unresolved questions

  • Currently all super-traits of Sized (i.e. Aligned, DynSized, and Object) are marked #[fundamental], but it is unclear whether we really need this attribute on them.
You can’t perform that action at this time.