Skip to content

Commit

Permalink
added simple example to include Option type
Browse files Browse the repository at this point in the history
increased version --> v0.3.1
  • Loading branch information
JoelBeicher committed Jul 20, 2023
1 parent 4cdc8a6 commit 63248db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leptos-struct-table"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = ["Marc-Stefan Cassola"]
categories = ["gui", "web-programming"]
Expand Down
18 changes: 13 additions & 5 deletions examples/simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ pub struct Book {
/// Author of the book.
pub author: String,
/// Date when book has been published.
pub publish_date: NaiveDate,
pub publish_date: Option<NaiveDate>,
/// Description of the book. Optional.
pub description: Option<String>,
/// Example on hidden member.
#[table(skip)]
pub hidden_field: String,
Expand All @@ -38,28 +40,34 @@ fn main() {
id: Uuid::default(),
title: "The Great Gatsby".to_string(),
author: "F. Scott Fitzgerald".to_string(),
publish_date: NaiveDate::from_ymd_opt(1925, 4, 10).unwrap(),
publish_date: Some(NaiveDate::from_ymd_opt(1925, 4, 10).unwrap()),
description: Some(
"A story of wealth, love, and the American Dream in the 1920s.".to_string(),
),
hidden_field: "hidden".to_string(),
},
Book {
id: Uuid::default(),
title: "The Grapes of Wrath".to_string(),
author: "John Steinbeck".to_string(),
publish_date: NaiveDate::from_ymd_opt(1939, 4, 14).unwrap(),
publish_date: Some(NaiveDate::from_ymd_opt(1939, 4, 14).unwrap()),
description: None,
hidden_field: "not visible in the table".to_string(),
},
Book {
id: Uuid::default(),
title: "Nineteen Eighty-Four".to_string(),
author: "George Orwell".to_string(),
publish_date: NaiveDate::from_ymd_opt(1949, 6, 8).unwrap(),
publish_date: Some(NaiveDate::from_ymd_opt(1949, 6, 8).unwrap()),
description: None,
hidden_field: "hidden".to_string(),
},
Book {
id: Uuid::default(),
title: "Ulysses".to_string(),
author: "James Joyce".to_string(),
publish_date: NaiveDate::from_ymd_opt(1922, 2, 2).unwrap(),
publish_date: Some(NaiveDate::from_ymd_opt(1922, 2, 2).unwrap()),
description: None,
hidden_field: "hidden".to_string(),
},
],
Expand Down

0 comments on commit 63248db

Please sign in to comment.