-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
type/enhancementNew feature or requestNew feature or request
Description
Now, the trait is:
pub trait KvsEngine: Send + Sync {
fn set(&mut self, key: String, value: String) -> Result<()>;
fn get(&self, key: String) -> Result<Option<String>>;
fn remove(&mut self, key: String) -> Result<()>;
}I think Result<()> of remove is not good typing, as it groups both key not found and other errors into one type. The signature of get is much better, as we can infer from the returned result:
Result(Some(...)): a corresponding value is foundResult(None): there is no corresponding valueError(...): error happened
My proposal is to have remove returns the same type as get:
pub trait KvsEngine: Send + Sync {
fn set(&mut self, key: String, value: String) -> Result<()>;
fn get(&self, key: String) -> Result<Option<String>>;
fn remove(&mut self, key: String) -> Result<Option<String>>;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/enhancementNew feature or requestNew feature or request