From f2fa3411d85d5c2c9e57721433933e4682a47d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 4 May 2023 11:27:47 +0200 Subject: [PATCH] Fix const Option::unwrap_or() Fixes #57 --- src/lib.rs | 1 - src/provider/github.rs | 6 ++++-- src/provider/gitlab.rs | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9304675..606cbe9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![feature(io_error_more)] -#![feature(const_option_ext)] #![forbid(unsafe_code)] use std::path::Path; diff --git a/src/provider/github.rs b/src/provider/github.rs index e495237..6b7ec21 100644 --- a/src/provider/github.rs +++ b/src/provider/github.rs @@ -9,8 +9,10 @@ use super::Project; use super::Provider; const ACCEPT_HEADER_JSON: &str = "application/vnd.github.v3+json"; -const GITHUB_API_BASEURL: &str = - option_env!("GITHUB_API_BASEURL").unwrap_or("https://api.github.com"); +const GITHUB_API_BASEURL: &str = match option_env!("GITHUB_API_BASEURL") { + Some(url) => url, + None => "https://api.github.com", +}; #[derive(Deserialize)] pub struct GithubProject { diff --git a/src/provider/gitlab.rs b/src/provider/gitlab.rs index b1a08b8..b149c26 100644 --- a/src/provider/gitlab.rs +++ b/src/provider/gitlab.rs @@ -9,7 +9,10 @@ use super::Project; use super::Provider; const ACCEPT_HEADER_JSON: &str = "application/json"; -const GITLAB_API_BASEURL: &str = option_env!("GITLAB_API_BASEURL").unwrap_or("https://gitlab.com"); +const GITLAB_API_BASEURL: &str = match option_env!("GITLAB_API_BASEURL") { + Some(url) => url, + None => "https://gitlab.com", +}; #[derive(Deserialize)] #[serde(rename_all = "lowercase")]