Skip to content

Instantly share code, notes, and snippets.

#[derive(Debug, Default, Validate, Deserialize,Clone)]
struct SignupData {
#[validate(email)]
mail: String,
#[validate(phone)]
phone: String,
#[validate(url)]
site: String,
#[validate(length(min = 1), custom = "validate_unique_username")]
#[serde(rename = "firstName")]
@rebo
rebo / form.rs
Last active July 22, 2020 21:11
#[derive(Debug, Validate, Deserialize)]
struct SignupData {
#[validate(email)]
mail: String,
#[validate(phone)]
phone: String,
#[validate(url)]
site: String,
#[validate(length(min = 1), custom = "validate_unique_username")]
// An example To-do seed application, includes filtering of todos
// Each UI component is naturally scoped to specific state changes.
// This makes each part understandable
// The UI elements are themselves `#[computed]` properties of the
// underyling state and only update if the underlying state changes.
#[derive(Clone)]
struct Todo{
idx: usize,
description: String,
// An example To-do seed application, includes filtering of todos
// Each UI component is naturally scoped to specific state changes.
// This makes each part understandable
// The UI elements are themselves `#[computed]` properties of the
// underyling state and only update if the underlying state changes.
#[derive(Clone)]
struct Todo{
idx: usize,
description: String,
#[derive(Clone)]
struct Todo{
idx: usize,
description: String,
complete: bool,
}
// Atom of state, a vector holding Todo structs
#[state]
#[view_macro]
fn showcard_view<Ms: 'static>(
opts: ShowOpts,
root: Node<Ms>,
_children: Vec<Node<Ms>>,
mut title: Node<Ms>,
mut description: Node<Ms>,
award: Vec<(Node<Ms>, AwardOpts)>,
) -> Node<Ms> {
struct RegisterId{
id: i32
}
struct FsValue {
value: String,
}
struct FsPointer{
value_at_mem_location:usize
@rebo
rebo / 01-test-code.rs
Created May 31, 2020 21:08
01-test-code.rs
#![feature(proc_macro_hygiene)]
use my_macros::{view_macro,process_part};
#[macro_export]
macro_rules! some_rando_global_name_hohoho_left {
() => {
println!("yes this prints 1");
}
}
extern crate proc_macro;
use self::proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::parse::{Parse, ParseStream, Result};
use syn::{parse_macro_input, Expr};
use syn::{ItemFn};
#[proc_macro_attribute]
fn basic_styled_counter() -> Node<Msg> {
div![
h3!["Basic Styled Counter"],
md![
r#"This is a basic styled button, the button is styled with the following
```
S.padding_left(px(24))
.padding_right(px(24))
.padding_top(px(8))