Some basic rust algorithms.

master
Tomasz Polgrabia 2025-03-01 11:41:14 +01:00
parent 2edf415e2a
commit 4463b79496
4 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1 @@
target

7
current/algorithms/rust_algo/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "rust_algo"
version = "0.1.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_algo"
version = "0.1.0"
edition = "2024"
[dependencies]

View File

@ -0,0 +1,19 @@
fn main() {
let mut v = [4.1, -5.1, 1.1, -3.1, 2.1];
v.sort_by(f64::total_cmp);
println!("Hello, world!");
for el in v {
println!("Element {}.", el);
}
let mut v = vec![5, 2, 1];
v.push(2);
v.push(5);
for (idx, elem) in v.iter().enumerate() {
println!("Val: {}. {}.", idx, elem);
}
println!("Done");
}