From 261ff36f9b6d51467ea3db9af0168cca51e56066 Mon Sep 17 00:00:00 2001 From: structix Date: Tue, 2 Aug 2022 16:57:42 +0200 Subject: [PATCH] Add maxnumber --- testaufgaben/.gitignore | 14 ++++++++++++++ testaufgaben/maxnumber/.gitignore | 14 ++++++++++++++ testaufgaben/maxnumber/Cargo.toml | 8 ++++++++ testaufgaben/maxnumber/src/main.rs | 11 +++++++++++ 4 files changed, 47 insertions(+) create mode 100644 testaufgaben/.gitignore create mode 100644 testaufgaben/maxnumber/.gitignore create mode 100644 testaufgaben/maxnumber/Cargo.toml create mode 100644 testaufgaben/maxnumber/src/main.rs diff --git a/testaufgaben/.gitignore b/testaufgaben/.gitignore new file mode 100644 index 0000000..6985cf1 --- /dev/null +++ b/testaufgaben/.gitignore @@ -0,0 +1,14 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/testaufgaben/maxnumber/.gitignore b/testaufgaben/maxnumber/.gitignore new file mode 100644 index 0000000..6985cf1 --- /dev/null +++ b/testaufgaben/maxnumber/.gitignore @@ -0,0 +1,14 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/testaufgaben/maxnumber/Cargo.toml b/testaufgaben/maxnumber/Cargo.toml new file mode 100644 index 0000000..e8a0330 --- /dev/null +++ b/testaufgaben/maxnumber/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "maxnumber" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/testaufgaben/maxnumber/src/main.rs b/testaufgaben/maxnumber/src/main.rs new file mode 100644 index 0000000..7694d66 --- /dev/null +++ b/testaufgaben/maxnumber/src/main.rs @@ -0,0 +1,11 @@ +use std::fmt::Error; + +fn main() -> Result<(), Error> { + let array = vec![1, 3, 3, 7]; + + if let Some(max) = array.iter().max() { + println!("Max. number: {}", max); + } + + Ok(()) +}