Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit b1aef602 authored by Andrew4Coding's avatar Andrew4Coding
Browse files

Implement delete function in Subscriber repository

parent ed556b2e
No related branches found
No related tags found
No related merge requests found
use std::result;
use dashmap::DashMap;
use lazy_static::lazy_static;
use crate::model::subscriber::Subscriber;
......@@ -31,4 +33,19 @@ impl SubscriberRepository {
return SUBSCRIBERS.get(product_type).unwrap().
iter().map(|f| f.value().clone()).collect();
}
pub fn delete(product_type: &str, url: &str) -> Option<Subscriber> {
if SUBSCRIBERS.get(product_type).is_none() {
SUBSCRIBERS.insert(String::from(product_type), DashMap::new());
};
let result = SUBSCRIBERS.get(product_type).unwrap().
remove(url);
if result.is_some() {
return Some(result.unwrap().1);
} else {
return None;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment