You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
The assignment syntax on its own is quite limiting because you can only assign to buffers that are the same size as each other. Indexing allows us to slice and copy parts of buffers into parts of other buffers. This is convenient while remaining memory-safe and easy to reason about.
Support the following syntax:
let a: [u8; _] = "Hello, world";
let b: [u8; _] = "abc";
// outputs "ello"
stdout.write(a[1..5]);
// still invalid:
// a = b;
// b = a;
// After this, a will be "Habco, world"
a[1..4] = b; // equivalent a[1..4] = b[..]
// After this, b will be "abd"
b[-1] = a[-1];
// Error to assign different sizes
//a[1..5] = b[1..];
The range syntax [start..end] contains the range of cells from start to end-1. You can leave off the start or end of the range to imply either 0 or (size - 1) respectively. Using a negative index (idx) is the same as saying length - idx.
The text was updated successfully, but these errors were encountered:
Depends on #46 before implementation.
The assignment syntax on its own is quite limiting because you can only assign to buffers that are the same size as each other. Indexing allows us to slice and copy parts of buffers into parts of other buffers. This is convenient while remaining memory-safe and easy to reason about.
Support the following syntax:
The range syntax
[start..end]
contains the range of cells fromstart
toend-1
. You can leave off the start or end of the range to imply either 0 or (size - 1) respectively. Using a negative index (idx
) is the same as sayinglength - idx
.The text was updated successfully, but these errors were encountered: