diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-03-22 20:07:02 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-03-22 20:07:02 +0200 |
commit | 6c23a928d2b86fee4a084a8e3fff671881531a8d (patch) | |
tree | 8e767e161542785f55101c803707110dfed2e62a | |
download | keyvalue-6c23a928d2b86fee4a084a8e3fff671881531a8d.tar.gz |
initial commit
Sponsored-by: author
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | Cargo.toml | 8 | ||||
-rw-r--r-- | src/main.rs | 28 |
4 files changed, 44 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..bf0469a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "keyvalue" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..6858834 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "keyvalue" +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/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3392039 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,28 @@ +struct Container<K: Eq, V> { + values: Vec<(K, V)>, +} + +impl<K: Eq, V> Container<K, V> { + fn new() -> Self { + Self { values: vec![] } + } + + fn insert(&mut self, k: K, v: V) { /* FIXME */ + } + + fn get(&self, k: &K) -> Option<&V> { + None + } +} + +fn main() { + let alice = "alice".to_string(); + let bob = "bob".to_string(); + let robert = "Robert".to_string(); + let mut cont = Container::new(); + cont.insert(bob.clone(), bob.clone()); + cont.insert(bob.clone(), robert); + println!("{} -> {:?}", &alice, cont.get(&alice)); + println!("{} -> {:?}", &bob, cont.get(&bob)); + // Output should be Robert +} |