structstd.RingBuffer.Slice[src]

A Slice represents a region of a ring buffer. The region is split into two sections as the ring buffer data will not be contiguous if the desired region wraps to the start of the backing slice.

Fields

first: []u8
second: []u8

Functions

FunctioncopyTo[src]

pub fn copyTo(self: Slice, dest: []u8) void

Copy data from self into dest

Parameters

self: Slice
dest: []u8

Source Code

Source code
pub fn copyTo(self: Slice, dest: []u8) void {
    @memcpy(dest[0..self.first.len], self.first);
    @memcpy(dest[self.first.len..][0..self.second.len], self.second);
}

Source Code

Source code
pub const Slice = struct {
    first: []u8,
    second: []u8,

    /// Copy data from `self` into `dest`
    pub fn copyTo(self: Slice, dest: []u8) void {
        @memcpy(dest[0..self.first.len], self.first);
        @memcpy(dest[self.first.len..][0..self.second.len], self.second);
    }
}