Bytes

lib/Bytes.gob

A ByteView is a run of bytes that can be read and not written: it has Index, Length and Iterator, and no SetIndex. Nothing here gives back the storage it reads.

String.view(s) views a string's bytes and Array.view(xs) an array's, neither by copying. A string is never written, so a view of one never changes. An array can be, by whoever holds it, and a view of it shows each write as it happens: the view is read-only, not frozen.

type ByteView

The length bytes of storage from storage[from] on, where from >= 0, length >= 0 and from + length <= len(storage). Every view is made in the library, which keeps that so: the word reads in Hash.Words check only against length, and rely on it to stay inside storage.

The view holds its length rather than its end because the hashers check every word they read against it, and an end would cost a subtraction, with its overflow test, per read.

instance Index ByteView

The i-th byte of the view.

instance Length ByteView
instance Debug ByteView

The viewed bytes and nothing else: where they sit in the storage is not part of the value.

instance Iterator ByteView

The view's bytes, front to back, each as it is when asked for.