Struct scratchpad::MarkerBack [] [src]

pub struct MarkerBack<'scratchpad, BufferT, TrackingT> where
    BufferT: 'scratchpad + Buffer,
    TrackingT: 'scratchpad + Tracking
{ /* fields omitted */ }

Scratchpad marker for allocations from the back of the allocation buffer.

A MarkerBack is created when calling the mark_back() method on a Scratchpad instance. Object allocations can only be made from the most recently created MarkerFront or MarkerBack that is still active.

Markers are statically bound to the lifetime of the Scratchpad from which they are created, ensuring that no dangling references are left when the Scratchpad is dropped.

This struct wraps Marker trait methods to avoid the need to import Marker into scope.

Methods

impl<'scratchpad, BufferT, TrackingT> MarkerBack<'scratchpad, BufferT, TrackingT> where
    BufferT: 'scratchpad + Buffer,
    TrackingT: 'scratchpad + Tracking
[src]

[src]

Allocates space for the given value, moving it into the allocation.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 1], [usize; 1]>::new([0], [0]);
let marker = scratchpad.mark_back().unwrap();

let x = marker.allocate(3.14159).unwrap();
assert_eq!(*x, 3.14159);

[src]

Allocates space for a value, initializing it to its default.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 1], [usize; 1]>::new([0], [0]);
let marker = scratchpad.mark_back().unwrap();

let x = marker.allocate_default::<f64>().unwrap();
assert_eq!(*x, 0.0);

[src]

Allocates uninitialized space for the given type.

Safety

Since memory for the allocated data is uninitialized, it can potentially be in an invalid state for a given type, leading to undefined program behavior. It is recommended that one of the safe allocate*() methods are used instead if possible.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 1], [usize; 1]>::new([0], [0]);
let marker = scratchpad.mark_back().unwrap();

let mut x = unsafe { marker.allocate_uninitialized().unwrap() };
*x = 3.14159;
assert_eq!(*x, 3.14159);

[src]

Allocates space for an array, initializing each element with the given value.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 3], [usize; 1]>::new([0; 3], [0]);
let marker = scratchpad.mark_back().unwrap();

let x = marker.allocate_array(3, 3.14159).unwrap();
assert_eq!(*x, [3.14159, 3.14159, 3.14159]);

[src]

Allocates space for an array, initializing each element to its default value.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 3], [usize; 1]>::new([0; 3], [0]);
let marker = scratchpad.mark_back().unwrap();

let x = marker.allocate_array_default::<f64>(3).unwrap();
assert_eq!(*x, [0.0, 0.0, 0.0]);

[src]

Allocates space for an array, initializing each element with the result of a function.

The function func takes a single parameter containing the index of the element being initialized.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 3], [usize; 1]>::new([0; 3], [0]);
let marker = scratchpad.mark_back().unwrap();

let x = marker.allocate_array_with(3, |index| index as f64).unwrap();
assert_eq!(*x, [0.0, 1.0, 2.0]);

[src]

Allocates uninitialized space for an array of the given type.

Safety

Since memory for the allocated data is uninitialized, it can potentially be in an invalid state for a given type, leading to undefined program behavior. It is recommended that one of the safe allocate*() methods are used instead if possible.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u64; 3], [usize; 1]>::new([0; 3], [0]);
let marker = scratchpad.mark_back().unwrap();

let mut x = unsafe {
    marker.allocate_array_uninitialized(3).unwrap()
};
x[0] = 3.14159;
x[1] = 4.14159;
x[2] = 5.14159;
assert_eq!(*x, [3.14159, 4.14159, 5.14159]);

[src]

Combines each of the provided strings into a single string slice allocated from this marker.

Examples

use scratchpad::Scratchpad;

let scratchpad = Scratchpad::<[u8; 16], [usize; 1]>::static_new();
let marker = scratchpad.mark_back().unwrap();

let combined = marker.concat(&["Hello,", " world", "!"]).unwrap();
assert_eq!(&*combined, "Hello, world!");

Trait Implementations

impl<'scratchpad, BufferT: Debug, TrackingT: Debug> Debug for MarkerBack<'scratchpad, BufferT, TrackingT> where
    BufferT: 'scratchpad + Buffer,
    TrackingT: 'scratchpad + Tracking
[src]

[src]

Formats the value using the given formatter. Read more

impl<'scratchpad, BufferT, TrackingT> Marker for MarkerBack<'scratchpad, BufferT, TrackingT> where
    BufferT: 'scratchpad + Buffer,
    TrackingT: 'scratchpad + Tracking
[src]

[src]

[src]

Allocates space for the given value, moving it into the allocation. Read more

[src]

Allocates space for a value, initializing it to its default. Read more

[src]

Allocates uninitialized space for the given type. Read more

[src]

Allocates space for an array, initializing each element with the given value. Read more

[src]

Allocates space for an array, initializing each element to its default value. Read more

[src]

Allocates space for an array, initializing each element with the result of a function. Read more

[src]

Allocates uninitialized space for an array of the given type. Read more

[src]

Combines each of the provided strings into a single string slice allocated from this marker. Read more

impl<'scratchpad, BufferT, TrackingT> Drop for MarkerBack<'scratchpad, BufferT, TrackingT> where
    BufferT: 'scratchpad + Buffer,
    TrackingT: 'scratchpad + Tracking
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'scratchpad, BufferT, TrackingT> !Send for MarkerBack<'scratchpad, BufferT, TrackingT>

impl<'scratchpad, BufferT, TrackingT> !Sync for MarkerBack<'scratchpad, BufferT, TrackingT>