Skip to main content

QuirkSink

Trait QuirkSink 

Source
pub trait QuirkSink<Msg> {
    // Required method
    fn put(&mut self, msg: Msg);
}
Expand description

Interface for messages regarding program quriks the user should be warned about.

Often Scratch tries to do something so that it doesn’t have to raise an exception or fatal error. It allows accessing a list out of bounds, computes modulo with floating point arguments, …

As the interpreter has to mimic this behaviour it also generates warnings when such behaviour is encountered as it could be considered bad practice. Every “quirky” operation can define an own type with possible warnings by requiring a qurik sink of the type.

It then would perform it’s operation according to Scratch semantics while still being able to emit warnings to the sink.

() is a valid sink for any message type so it can be used to ignore any message an operation might send.

Required Methods§

Source

fn put(&mut self, msg: Msg)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<M> QuirkSink<M> for ()

Source§

fn put(&mut self, _: M)

Implementors§