`cargo fmt`

This commit is contained in:
Greg Johnston 2023-01-20 10:08:13 -05:00
parent 285092a467
commit a964e89d1a
4 changed files with 246 additions and 244 deletions

View File

@ -39,8 +39,8 @@ fn leptos_ssr_bench(b: &mut Bencher) {
#[bench] #[bench]
fn tera_ssr_bench(b: &mut Bencher) { fn tera_ssr_bench(b: &mut Bencher) {
use serde::{Deserialize, Serialize};
use tera::*; use tera::*;
use serde::{Serialize, Deserialize};
static TEMPLATE: &str = r#"<main> static TEMPLATE: &str = r#"<main>
<h1>Welcome to our benchmark page.</h1> <h1>Welcome to our benchmark page.</h1>
@ -64,16 +64,19 @@ fn tera_ssr_bench(b: &mut Bencher) {
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct Counter { struct Counter {
value: i32 value: i32,
} }
b.iter(|| { b.iter(|| {
let mut ctx = Context::new(); let mut ctx = Context::new();
ctx.insert("counters", &vec![ ctx.insert(
"counters",
&vec![
Counter { value: 0 }, Counter { value: 0 },
Counter { value: 1}, Counter { value: 1 },
Counter { value: 2 } Counter { value: 2 },
]); ],
);
let _ = TERA.render("template.html", &ctx).unwrap(); let _ = TERA.render("template.html", &ctx).unwrap();
}); });
@ -81,8 +84,8 @@ fn tera_ssr_bench(b: &mut Bencher) {
#[bench] #[bench]
fn sycamore_ssr_bench(b: &mut Bencher) { fn sycamore_ssr_bench(b: &mut Bencher) {
use sycamore::*;
use sycamore::prelude::*; use sycamore::prelude::*;
use sycamore::*;
b.iter(|| { b.iter(|| {
_ = create_scope(|cx| { _ = create_scope(|cx| {

View File

@ -75,12 +75,7 @@ impl Todo {
Self::new_with_completed(cx, id, title, false) Self::new_with_completed(cx, id, title, false)
} }
pub fn new_with_completed( pub fn new_with_completed(cx: Scope, id: usize, title: String, completed: bool) -> Self {
cx: Scope,
id: usize,
title: String,
completed: bool,
) -> Self {
let (title, set_title) = create_signal(cx, title); let (title, set_title) = create_signal(cx, title);
let (completed, set_completed) = create_signal(cx, completed); let (completed, set_completed) = create_signal(cx, completed);
Self { Self {
@ -93,8 +88,7 @@ impl Todo {
} }
pub fn toggle(&self) { pub fn toggle(&self) {
self self.set_completed
.set_completed
.update(|completed| *completed = !*completed); .update(|completed| *completed = !*completed);
} }
} }
@ -103,7 +97,7 @@ const ESCAPE_KEY: u32 = 27;
const ENTER_KEY: u32 = 13; const ENTER_KEY: u32 = 13;
#[component] #[component]
pub fn TodoMVC(cx: Scope,todos: Todos) -> impl IntoView { pub fn TodoMVC(cx: Scope, todos: Todos) -> impl IntoView {
let mut next_id = todos let mut next_id = todos
.0 .0
.iter() .iter()

View File

@ -14,7 +14,9 @@ fn leptos_todomvc_ssr(b: &mut Bencher) {
let rendered = view! { let rendered = view! {
cx, cx,
<TodoMVC todos=Todos::new(cx)/> <TodoMVC todos=Todos::new(cx)/>
}.into_view(cx).render_to_string(cx); }
.into_view(cx)
.render_to_string(cx);
assert!(rendered.len() > 1); assert!(rendered.len() > 1);
}); });

View File

@ -417,6 +417,9 @@ fn to_kebab_case(name: &str) -> String {
} }
#[doc(hidden)] #[doc(hidden)]
pub fn escape_attr<T>(value: &T) -> Cow<'_, str> where T: AsRef<str>{ pub fn escape_attr<T>(value: &T) -> Cow<'_, str>
where
T: AsRef<str>,
{
html_escape::encode_double_quoted_attribute(value) html_escape::encode_double_quoted_attribute(value)
} }