#![feature(generators, generator_trait)] mod BarPlugin; mod dropdown; use std::cell::RefCell; use std::ops::{Generator, GeneratorState}; use std::pin::Pin; use std::rc::Rc; use anyhow::Result; use insertSortGenerator::{insert_sort, test}; use notan::draw::*; use notan::draw::{CreateDraw, CreateFont, DrawConfig, Font}; use notan::prelude::*; mod insertSortGenerator; #[derive(AppState)] struct State { gen: Box>>, Return = ()>>, delay: f32, lastStepTime: f32, font: Font, next: Option, finished: bool, } fn setup(gfx: &mut Graphics) -> State { let mut arr = (1..=100).collect::>(); let gen = insert_sort(arr); State { gen: Box::new(gen), delay: 1., lastStepTime: 1., font: gfx .create_font(include_bytes!("./assets/LDF-ComicSans/LDFComicSans.ttf")) .unwrap(), next: None, finished: false, } } #[notan_main] fn main() -> Result<(), String> { notan::init_with(setup) .update(update) .draw(draw) .add_config(DrawConfig) .build() } fn update(state: &mut State) { if !state.finished { match Pin::new(&mut state.gen).resume(()) { GeneratorState::Yielded(a) => { state.next = Some(format!("{:?}", a)); println!("We set something") } GeneratorState::Complete(_) => { state.finished = true; println!("Generator finished"); } } }; } fn draw(gfx: &mut Graphics, state: &mut State) { let mut draw = gfx.create_draw(); draw.clear(Color::BLACK); let text = if state.next.is_some() { state.next.clone().unwrap() } else { String::new() }; gfx.render(&draw); } fn drawArr(draw: &mut Draw, screen_width: u32, screen_height: u32){ draw.rect(, size) }