Struct cpr_bf::VMBuilder

source ·
pub struct VMBuilder<T: BrainfuckCell = u8, A: BrainfuckAllocator = DynamicAllocator, R: Read = Stdin, W: Write = Stdout> { /* private fields */ }
Expand description

A builder struct for the default implementation of BrainfuckVM Create the default configuration with VMBuilder::new() or VMBuilder::default(), customize with the member functions, and build the final VM with VMBuilder::build()

Implementations§

source§

impl VMBuilder

source

pub fn new() -> VMBuilder

Construct a new VMBuilder with the default initial configuration

source§

impl<T: BrainfuckCell + 'static, A: BrainfuckAllocator + 'static, R: Read + 'static, W: Write + 'static> VMBuilder<T, A, R, W>

source

pub fn with_cell_type<U: BrainfuckCell>(self) -> VMBuilder<U, A, R, W>

Changes the type of the memory cells to U

source

pub fn with_allocator<U: BrainfuckAllocator>(self) -> VMBuilder<T, U, R, W>

Changes the used allocator to U

source

pub fn with_preallocated_cells( self, num_preallocated: usize ) -> VMBuilder<T, A, R, W>

Changes the amount of pre-allocated cells to num_preallocated

source

pub fn with_reader<U: Read>(self, reader: U) -> VMBuilder<T, A, U, W>

Changes the reader used by the VM as input for the running Brainfuck programs to reader

source

pub fn with_writer<U: Write>(self, writer: U) -> VMBuilder<T, A, R, U>

Changes the writer used by the VM as output for the running Brainfuck programs to writer

source

pub fn build(self) -> Box<dyn BrainfuckVM>

Builds the BrainfuckVM with the currently stored configuration of this builder

Trait Implementations§

source§

impl Default for VMBuilder

source§

fn default() -> Self

Construct a new VMBuilder with the default initial configuration

source§

impl<T: BrainfuckCell, A: BrainfuckAllocator, R: Read, W: Write> Display for VMBuilder<T, A, R, W>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, A, R, W> Freeze for VMBuilder<T, A, R, W>
where R: Freeze, W: Freeze,

§

impl<T, A, R, W> RefUnwindSafe for VMBuilder<T, A, R, W>

§

impl<T, A, R, W> Send for VMBuilder<T, A, R, W>
where A: Send, R: Send, T: Send, W: Send,

§

impl<T, A, R, W> Sync for VMBuilder<T, A, R, W>
where A: Sync, R: Sync, T: Sync, W: Sync,

§

impl<T, A, R, W> Unpin for VMBuilder<T, A, R, W>
where A: Unpin, R: Unpin, T: Unpin, W: Unpin,

§

impl<T, A, R, W> UnwindSafe for VMBuilder<T, A, R, W>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.