Merge branch 'main' of git.zekro.de:zekro/type-level-demo
This commit is contained in:
commit
ba799bd47b
11 files changed
+179
-53
No files matched your search
@@ -11,7 +11,7 @@ struct CredentialManager<State = Locked> {
|
||||
}
|
||||
|
||||
impl CredentialManager {
|
||||
pub fn new() -> CredentialManager<Locked> {
|
||||
pub fn new() -> CredentialManager {
|
||||
CredentialManager {
|
||||
entries: HashMap::new(),
|
||||
state: std::marker::PhantomData,
|
||||
@@ -46,9 +46,9 @@ impl CredentialManager<Unlocked> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let pw = CredentialManager::new();
|
||||
let mut pw = pw.unlock("pssst");
|
||||
pw.set("foo", "bar");
|
||||
let val = pw.get("foo");
|
||||
pw.lock();
|
||||
let pw_locked = CredentialManager::new();
|
||||
let mut pw_unlocked = pw_locked.unlock("pssst");
|
||||
pw_unlocked.set("foo", "bar");
|
||||
let val = pw_unlocked.get("foo");
|
||||
let pw_locked = pw_unlocked.lock();
|
||||
}
|
||||
Reference in new issue
Block a user