1. Home
  2. /
  3. Seed-rust
  4. /
  5. Seed Todo List

Seed Todo List - Seed-rust Typing CST Test

Loading…

Seed Todo List — Seed-rust Code

A basic Todo list component using Seed.

# seed/demo/todo.rs
use seed::{prelude::*, *};

struct Model { todos: Vec<String>, input: String }

enum Msg { Add, UpdateInput(String) }

fn init(_: Url, _: &mut Orders<Msg>) -> Model {
	Model { todos: vec![], input: String::new() }
}

fn update(msg: Msg, model: &mut Model, _: &mut Orders<Msg>) {
	match msg {
		Msg::Add => {
		model.todos.push(model.input.clone());
		model.input.clear();
		},
		Msg::UpdateInput(value) => model.input = value,
	}
}

fn view(model: &Model) -> Node<Msg> {
	div![
		input![
		type_("text"),
		attrs! { At::Value => model.input },
		ev(Ev::Input, |e| Msg::UpdateInput(e.value))
		],
		button![ev(Ev::Click, |_| Msg::Add), "Add"],
		ul![model.todos.iter().map(|todo| li![todo]).collect::<Vec<Node<Msg>>>()]
	]
}

#[wasm_bindgen(start)]
pub fn start() {
	App::start("app", init, update, view);
}

Seed-rust Language Guide

Seed is a Rust framework for creating front-end web apps with WebAssembly. It provides a component-based architecture inspired by Elm, enabling Rust developers to write type-safe, reactive web applications that compile to Wasm.

Primary Use Cases

  • ▸Single-page web applications (SPAs) in Rust
  • ▸High-performance dashboards and visualizations
  • ▸Interactive web games
  • ▸Wasm modules for web apps with Rust logic
  • ▸Integration-heavy front-end apps needing Rust crates

Notable Features

  • ▸Component-based architecture similar to Elm
  • ▸Virtual DOM for efficient UI updates
  • ▸Reactive message-driven state management
  • ▸Rust-to-Wasm compilation for high performance
  • ▸Works with wasm-bindgen to access JS and Web APIs

Origin & Creator

Seed was created by IcedDev and the Rust community, first appearing around 2018.

Industrial Note

Seed-Rust is ideal for developers who want Rust’s safety and performance for front-end web apps, especially for Wasm-based projects where speed and correctness are critical.

More Seed-rust Typing Exercises

Simple Seed ComponentSeed Component with ButtonSeed Counter ComponentSeed Component with Conditional RenderingSeed List RenderingSeed Component with Input BindingSeed Component with Click CounterSeed Component with Multiple Elements

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher