refactor code to use Shrinkwraprs and diesel-derive-newtype (#598)
* add shrinkwraprs and implement Id thru it This also means we can automatically convert Id to String without using .into()! * cleanup with the help of clippy! * cleanup with the help of cargo fmt! * remove extra block * Shrinkwrap Page, ContentLen and RemoteForm * translations
This commit is contained in:
committed by
Baptiste Gelez
parent
59023e9602
commit
8c59c822b6
@@ -163,18 +163,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Shrinkwrap, Clone, Serialize, Deserialize)]
|
||||
pub struct Id(String);
|
||||
|
||||
impl Id {
|
||||
pub fn new<T: Into<String>>(id: T) -> Id {
|
||||
Id(id.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<String> for Id {
|
||||
fn into(self) -> String {
|
||||
self.0.clone()
|
||||
pub fn new(id: impl ToString) -> Id {
|
||||
Id(id.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ extern crate reqwest;
|
||||
extern crate rocket;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate shrinkwraprs;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
|
||||
Reference in New Issue
Block a user