Skip to content

Commit ec859bb

Browse files
committed
models::badge: Inline encodable() method
1 parent afa0e74 commit ec859bb

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/models/badge.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::collections::HashMap;
55

66
use crate::models::Crate;
77
use crate::schema::badges;
8-
use crate::views::EncodableBadge;
98

109
/// A combination of a `Badge` and a crate ID.
1110
///
@@ -108,11 +107,6 @@ impl Queryable<badges::SqlType, Pg> for Badge {
108107
}
109108

110109
impl Badge {
111-
pub fn encodable(self) -> EncodableBadge {
112-
// The serde attributes on Badge ensure it can be deserialized to EncodableBadge
113-
serde_json::from_value(serde_json::to_value(self).unwrap()).unwrap()
114-
}
115-
116110
pub fn update_crate(
117111
conn: &PgConnection,
118112
krate: &Crate,

src/views.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub struct EncodableBadge {
1212

1313
impl From<Badge> for EncodableBadge {
1414
fn from(badge: Badge) -> Self {
15-
badge.encodable()
15+
// The serde attributes on Badge ensure it can be deserialized to EncodableBadge
16+
serde_json::from_value(serde_json::to_value(badge).unwrap()).unwrap()
1617
}
1718
}
1819

0 commit comments

Comments
 (0)