Created
September 29, 2022 13:29
-
-
Save SaraVieira/dd8f80d8ffa6a7c523b386058e4e8024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = Options { | |
file: options.file, | |
dist: options.dist, | |
..Options::default() | |
}; | |
// ALWAYS RETURNS EMPTY | |
println!("{:?}", a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::{self}; | |
use std::path::Path; | |
use toml::Value; | |
use twelf::config; | |
pub struct Downloads {} | |
// enum Theme { | |
// Light, | |
// Dark, | |
// } | |
#[config] | |
#[derive(Debug, Eq, PartialEq)] | |
pub struct Options { | |
// Your Readme.md name | |
pub file: Option<String>, | |
pub dist: Option<String>, | |
// pub name: String, | |
// pub logo: String, | |
// pub shareCard: String, | |
// pub homepage: String, | |
pub no_header: Option<bool>, | |
// pub theme: Theme, | |
// pub description: String, | |
} | |
impl Default for Options { | |
fn default() -> Self { | |
let mut name = String::new(); | |
let cargo_file = "Cargo.toml"; | |
if Path::new(cargo_file).exists() { | |
let file = fs::read_to_string(cargo_file).unwrap(); | |
println!("{:?}", file) | |
}; | |
Options { | |
file: Some("Readme".to_string()), | |
dist: Some("public".to_string()), | |
no_header: Some(false), | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment