diff --git a/src/rapr.rs b/src/rapr.rs index a91fdc54..a6f4c2aa 100644 --- a/src/rapr.rs +++ b/src/rapr.rs @@ -106,16 +106,21 @@ pub struct RaSub { after: Option, } -impl RaSub { - /// Generate subreddit object - pub fn new(name: &str) -> RaSub { - RaSub { +impl From<&str> for RaSub { + fn from(name: &str) -> Self { + Self { name: String::from(name), posts: Vec::new(), after: None, } } } +impl RaSub { + /// Generate subreddit object + pub fn new(name: &str) -> Self { + Self::from(name) + } +} /// Reddit api client. /// Uses a [reqwest::Client](https://docs.rs/reqwest/0.11.2/reqwest/struct.Client.html) internally.