aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-06-23 14:48:19 +0200
committerMartin Fischer <martin@push-f.com>2021-06-23 14:48:28 +0200
commit11c34f83641b36c7e09346fd00aed70ebd00dc64 (patch)
treefe0f689354f5a5aa1414b82198111abdbda55b78
parentcde4098bb72e164524d403f626dde96913d83316 (diff)
stop using #![feature] to support stable Rust
-rw-r--r--src/controller.rs22
-rw-r--r--src/main.rs2
2 files changed, 12 insertions, 12 deletions
diff --git a/src/controller.rs b/src/controller.rs
index f1bda33..1f66b44 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -121,19 +121,21 @@ struct Identity {
email: String,
}
+fn parse_identities(repo: &Repository) -> Option<Identities> {
+ let rev = repo.revparse_single("refs/heads/gitpad").ok()?;
+ let commit = rev.into_commit().ok()?;
+ let tree = commit.tree().ok()?;
+ let entry = tree.get_path(Path::new("users.toml")).ok()?;
+ let blob = repo.find_blob(entry.id()).ok()?;
+ toml::from_slice(blob.content()).ok()?
+}
+
impl MultiUserController {
pub fn new(repo: &Repository) -> Self {
- let identities: Option<Identities> = try {
- let rev = repo.revparse_single("refs/heads/gitpad").ok()?;
- let commit = rev.into_commit().ok()?;
- let tree = commit.tree().ok()?;
- let entry = tree.get_path(Path::new("users.toml")).ok()?;
- let blob = repo.find_blob(entry.id()).ok()?;
- toml::from_slice(blob.content()).ok()?
- };
-
Self {
- identities: RwLock::new(identities.unwrap_or_else(|| Identities(HashMap::new()))),
+ identities: RwLock::new(
+ parse_identities(repo).unwrap_or_else(|| Identities(HashMap::new())),
+ ),
shares_cache: RwLock::new(HashMap::new()),
}
}
diff --git a/src/main.rs b/src/main.rs
index fb6b544..d521087 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,3 @@
-#![feature(try_blocks)]
-
use clap::Clap;
use controller::Controller;
use git2::BranchType;