Add from to RaSub
This commit is contained in:
+9
-4
@@ -106,16 +106,21 @@ pub struct RaSub {
|
||||
after: Option<String>,
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user