Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 553 Bytes

File metadata and controls

24 lines (19 loc) · 553 Bytes

View Structs

A standard struct cannot contain a view struct field.

A view struct is a special type of struct designed for transient data access.

  • strictly limited to the stack
  • a view struct can only be a field within another view struct
  • cannot be used as a generic argument by default
  • cannot be used with using, have using fields and destructor
view struct Span<T>
{
    view T _ptr;
    int _length;

    public Span(view T ptr, int length)
    {
        _ptr = ptr;
        _length = length;
    }
}