23 lines
774 B
Plaintext
23 lines
774 B
Plaintext
#! @file viewable.sakura
|
|||
|
|
#! @author John Christman (sorakatadzuma@gmail.com)
|
||
|
|
#! @copyright Malunal Studios, LLC.
|
||
|
|
#! @license MIT
|
||
|
|
#!
|
||
|
|
#! Contains the viewable trait, which a type implements to lend a view of the
|
||
|
|
#! elements it holds, and to be given wherever such a view is wanted.
|
||
|
|
|
||
|
|
module core;
|
||
|
|
|
||
|
|
#! A type that lends a view of the elements it holds, as a `string` lends its
|
||
|
|
#! text and a container its elements.
|
||
|
|
#!
|
||
|
|
#! Generic code bounded by it reads the elements of whatever it is given through
|
||
|
|
#! `view`.
|
||
|
|
#! @tparam T The type of the elements.
|
||
|
|
pub trait viewable<T> {
|
||
|
|
#! Lends a view of the elements, without copying them.
|
||
|
|
#! @param this The value to view.
|
||
|
|
#! @returns The view, which is only good until the value changes or closes.
|
||
|
|
def view(&this): span<T>;
|
||
|
|
}
|
||
|
|
|