slice.rst 654 B

12345678910111213141516171819202122232425
  1. .. SPDX-License-Identifier: GPL-2.0 or GPL-3.0
  2. .. Copyright © 2019 Ariadne Devos
  3. .. index::
  4. single: slice
  5. Slices: positive-length array ranges
  6. ====================================
  7. Slices point to a region in memory, of a certain length.
  8. s² took the concept from Rust [#frustslice]_. Due to
  9. Spectre mitigation issues, slices typically must be
  10. positive in length.
  11. A slice is specified as SliceCap<impl T>(c: T& -> Cap, length:
  12. nat, p: T \*), where `c` indicates the capability.
  13. SliceCap<impl T>(c: T& -> Cap, length: nat, p: T *) :=
  14. 0 <= length <= SIZE_MAX,
  15. ∀{i | 0 <= i < length} (c . (index a))
  16. .. rubric:: footnotes
  17. XXX Rust reference