Giter VIP home page Giter VIP logo

rust-course's People

Contributors

kharianne avatar

Watchers

 avatar

rust-course's Issues

Minor feedback

pub mod operations {

Tohle je zbytečný, modul je definovanej už tim souborem samotnym, takhle máš crate::operations::operations :)

pub const AVAILABLE_OPERATIONS: [&str; 7] = [
"lowercase",
"uppercase",
"no-spaces",
"slugify",
"reverse",
"title-case",
"csv",
];
// Defined the enum with allowed values from string modifications
enum StringOperation {
Lowercase,
Uppercase,
NoSpaces,
Slugify,
Reverse,
TitleCase,
Csv,
}
impl FromStr for StringOperation {
// Read the string from arg and convert it to the enum
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"uppercase" => Ok(StringOperation::Uppercase),
"lowercase" => Ok(StringOperation::Lowercase),
"reverse" => Ok(StringOperation::Reverse),
"no-spaces" => Ok(StringOperation::NoSpaces),
"slugify" => Ok(StringOperation::Slugify),
"title-case" => Ok(StringOperation::TitleCase),
"csv" => Ok(StringOperation::Csv),
_ => Err(format!(
"Unknown modification: {s}\nAvailable modifications: {mods}",
s = s,
mods = AVAILABLE_OPERATIONS.join(", ")
)),
}
}
}

Pro zajímavost, ještě jsme si to neukazovali, ale tohle lepidlo dokáže vygenerovat crate zvanej strum

Jinak pěkný, pusť si na tom cargo clippy na drobnosti jako zbytečný returny a podobně

Minor feedback

loop {
println!("Enter your name: ");
io::stdin()
.read_line(&mut input)
.expect("Failed to read user input");
if input.trim().is_empty() {
println!("Please enter some name...");
continue;
} else {
println!("Hello, {}! Nice to meet you!", input.trim());
break;
}
}
}

Very good, you could also try using loop as an expression and break with a name when the user finally gives it to you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.