struct Slice(T)

Overview

A Slice is a Pointer with an associated size.

While a pointer is unsafe because no bound checks are performed when reading from and writing to it, reading from and writing to a slice involve bound checks. In this way, a slice is a safe alternative to Pointer.

A Slice can be created as read-only: trying to write to it will raise. For example the slice of bytes returned by String#to_slice is read-only.

Included Modules

Defined in:

cannon/core_ext.cr

Class Method Summary

Instance Method Summary

Class methods inherited from class Object

to_cannon_io(io, value) to_cannon_io

Class Method Detail

def self.from_cannon_io(io) #

Creates a Slice from io.


[View source]

Instance Method Detail

def to_cannon_io(io) #

Writes the Slice into io.


[View source]