Trait WithRander

Source
pub trait WithRander: Clone + PartialEq {
    // Required method
    fn rand(self, canvas: &HtmlCanvasElement);
}
Expand description

Implement this trait for rendering.

use &self to pass data.

§example

#[derive(Clone, PartialEq)]
struct Rander();

impl WithRander for Rander {
   fn rand(self, canvas: &HtmlCanvasElement) {
   // CanvasRenderingContext2d can be
   // any kind of canvas context.
   // Make sure that, it's the same
   // context as Canvas component.
       let interface: CanvasRenderingContext2d = canvas
           .get_context("2d")
           .unwrap()
           .unwrap()
           .dyn_into()
           .unwrap();
   ...

Required Methods§

Source

fn rand(self, canvas: &HtmlCanvasElement)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§