January 2019
Intermediate to advanced
520 pages
14h 32m
English
When we don't need data anymore, we can delete it. This is the purpose of the DELETE method. Use it in the branch as follows:
(&Method::DELETE, Some(id)) => { if users.contains(id) { users.remove(id); response_with_code(StatusCode::OK) } else { response_with_code(StatusCode::NOT_FOUND) }},
This code checks whether the Slab contains the data and removes it with the remove method. We don't use the remove method right away because this expects the data to exist in the storage beforehand, and therefore panics if the data is absent.
Read now
Unlock full access