Require a main function in all exercises

This commit is contained in:
mo8it
2024-04-17 22:46:21 +02:00
parent d83cc69afe
commit cb9f1ac9ce
39 changed files with 199 additions and 44 deletions
+4
View File
@@ -9,6 +9,10 @@
// Execute `rustlings hint errors1` or use the `hint` watch subcommand for a
// hint.
fn main() {
// You can optionally experiment here.
}
pub fn generate_nametag_text(name: String) -> Option<String> {
if name.is_empty() {
// Empty names aren't allowed.
+4
View File
@@ -29,6 +29,10 @@ pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
Ok(qty * cost_per_item + processing_fee)
}
fn main() {
// You can optionally experiment here.
}
#[cfg(test)]
mod tests {
use super::*;
+4
View File
@@ -19,6 +19,10 @@ impl PositiveNonzeroInteger {
}
}
fn main() {
// You can optionally experiment here.
}
#[test]
fn test_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok());
+4
View File
@@ -54,6 +54,10 @@ impl PositiveNonzeroInteger {
}
}
fn main() {
// You can optionally experiment here.
}
#[cfg(test)]
mod test {
use super::*;