From f8971cea4f8f916bbb528169f06c513c2a18802e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 May 2021 17:14:25 +0200 Subject: main::update(): Update repository description on fetch update If the repository was updated, write the description into the `description` file. Add a `github::Repo.description()` method to get an empty string if the description is `None`. This facilitates writing to the `description` file. --- src/github.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/github.rs') diff --git a/src/github.rs b/src/github.rs index 0b20abd..b937f9b 100644 --- a/src/github.rs +++ b/src/github.rs @@ -31,6 +31,15 @@ pub struct Repo { pub updated_at: String, // TODO: Maybe parse to date? } +impl Repo { + /// Get the repository description or an empty string if `None`. + pub fn description(&self) -> &str { + self.description + .as_deref() + .unwrap_or("") + } +} + pub fn fetch_repos() -> Result, Error> { let mut headers = reqwest::header::HeaderMap::new(); -- cgit v1.2.3