Add from to RaSub
This commit is contained in:
+9
-4
@@ -106,16 +106,21 @@ pub struct RaSub {
|
|||||||
after: Option<String>,
|
after: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RaSub {
|
impl From<&str> for RaSub {
|
||||||
/// Generate subreddit object
|
fn from(name: &str) -> Self {
|
||||||
pub fn new(name: &str) -> RaSub {
|
Self {
|
||||||
RaSub {
|
|
||||||
name: String::from(name),
|
name: String::from(name),
|
||||||
posts: Vec::new(),
|
posts: Vec::new(),
|
||||||
after: None,
|
after: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl RaSub {
|
||||||
|
/// Generate subreddit object
|
||||||
|
pub fn new(name: &str) -> Self {
|
||||||
|
Self::from(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Reddit api client.
|
/// Reddit api client.
|
||||||
/// Uses a [reqwest::Client](https://docs.rs/reqwest/0.11.2/reqwest/struct.Client.html) internally.
|
/// Uses a [reqwest::Client](https://docs.rs/reqwest/0.11.2/reqwest/struct.Client.html) internally.
|
||||||
|
|||||||
Reference in New Issue
Block a user