Make benches compile
This commit is contained in:
9 files changed
+60
-62
No files matched your search
@@ -57,7 +57,7 @@ fn tui_update(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Props, PartialEq)]
|
||||
#[derive(Props, PartialEq, Clone)]
|
||||
struct BoxProps {
|
||||
x: usize,
|
||||
y: usize,
|
||||
@@ -65,15 +65,15 @@ struct BoxProps {
|
||||
alpha: f32,
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
fn Box(cx: ScopeState<BoxProps>) -> Element {
|
||||
fn Box(props: BoxProps) -> Element {
|
||||
let count = use_signal(|| 0);
|
||||
|
||||
let x = cx.props.x * 2;
|
||||
let y = cx.props.y * 2;
|
||||
let hue = cx.props.hue;
|
||||
let display_hue = cx.props.hue as u32 / 10;
|
||||
let count = count.get();
|
||||
let alpha = cx.props.alpha + (count % 100) as f32;
|
||||
let x = props.x * 2;
|
||||
let y = props.y * 2;
|
||||
let hue = props.hue;
|
||||
let display_hue = props.hue as u32 / 10;
|
||||
let count = count();
|
||||
let alpha = props.alpha + (count % 100) as f32;
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
@@ -88,24 +88,24 @@ fn Box(cx: ScopeState<BoxProps>) -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Props, PartialEq)]
|
||||
#[derive(Props, PartialEq, Clone)]
|
||||
struct GridProps {
|
||||
size: usize,
|
||||
update_count: usize,
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
fn Grid(cx: ScopeState<GridProps>) -> Element {
|
||||
let size = cx.props.size;
|
||||
let count = use_signal(|| 0);
|
||||
let counts = use_signal(|| vec![0; size * size]);
|
||||
fn Grid(props: GridProps) -> Element {
|
||||
let size = props.size;
|
||||
let mut count = use_signal(|| 0);
|
||||
let mut counts = use_signal(|| vec![0; size * size]);
|
||||
|
||||
let ctx: TuiContext = cx.consume_context().unwrap();
|
||||
if *count.get() + cx.props.update_count >= (size * size) {
|
||||
let ctx: TuiContext = consume_context();
|
||||
if count() + props.update_count >= (size * size) {
|
||||
ctx.quit();
|
||||
} else {
|
||||
for _ in 0..cx.props.update_count {
|
||||
for _ in 0..props.update_count {
|
||||
counts.with_mut(|c| {
|
||||
let i = *count.current();
|
||||
let i = count();
|
||||
c[i] += 1;
|
||||
c[i] %= 360;
|
||||
});
|
||||
@@ -121,44 +121,34 @@ fn Grid(cx: ScopeState<GridProps>) -> Element {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
(0..size).map(|x|
|
||||
{
|
||||
rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "row",
|
||||
(0..size).map(|y|
|
||||
{
|
||||
let alpha = y as f32*100.0/size as f32 + counts.read()[x*size + y] as f32;
|
||||
let key = format!("{}-{}", x, y);
|
||||
rsx! {
|
||||
Box{
|
||||
x: x,
|
||||
y: y,
|
||||
alpha: 100.0,
|
||||
hue: alpha,
|
||||
key: "{key}",
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
for x in 0..size {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "row",
|
||||
for y in 0..size {
|
||||
Box {
|
||||
key: "{x}-{y}",
|
||||
x: x,
|
||||
y: y,
|
||||
alpha: 100.0,
|
||||
hue: y as f32*100.0/size as f32 + counts.read()[x*size + y] as f32,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn app(cx: ScopeState<GridProps>) -> Element {
|
||||
fn app(props: GridProps) -> Element {
|
||||
rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{
|
||||
size: cx.props.size,
|
||||
update_count: cx.props.update_count,
|
||||
size: props.size,
|
||||
update_count: props.update_count,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ pub fn launch_cfg(app: fn() -> Element, cfg: Config) {
|
||||
launch_vdom_cfg(VirtualDom::new(app), cfg)
|
||||
}
|
||||
|
||||
pub fn launch_cfg_with_props<P: Clone + 'static>(app: fn(P) -> Element, props: P, cfg: Config) {
|
||||
launch_vdom_cfg(VirtualDom::new_with_props(app, props), cfg)
|
||||
}
|
||||
|
||||
pub fn launch_vdom_cfg(vdom: VirtualDom, cfg: Config) {
|
||||
dioxus_html::set_event_converter(Box::new(events::SerializedHtmlEventConverter));
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ fn key_down() {
|
||||
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
|
||||
spawn(async move {
|
||||
@@ -77,7 +77,7 @@ fn mouse_down() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(2).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -113,7 +113,7 @@ fn mouse_up() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -151,7 +151,7 @@ fn mouse_enter() {
|
||||
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
@@ -191,7 +191,7 @@ fn mouse_exit() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -230,7 +230,7 @@ fn mouse_move() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -269,7 +269,7 @@ fn wheel() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -309,7 +309,7 @@ fn click() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
@@ -348,7 +348,7 @@ fn context_menu() {
|
||||
fn app() -> Element {
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let mut render_count_handle = render_count;
|
||||
spawn(async move {
|
||||
PollN::new(3).await;
|
||||
render_count_handle.with_mut(|x| *x + 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Launch helper macros for fullstack apps
|
||||
|
||||
#![allow(clippy::new_without_default)]
|
||||
#![allow(unused)]
|
||||
use std::any::Any;
|
||||
|
||||
|
||||
Reference in new issue
Block a user