aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-16 02:27:00 +0000
committerFuwn <[email protected]>2023-04-16 02:27:00 +0000
commitb0950591e869d2ffeed4ae8e4ad7f91a901449ff (patch)
tree8fb8b8daca8f85201a0cb676b85f6ccf5b715ac6
parentrefactor: optimise more arguments (diff)
downloadgerm-b0950591e869d2ffeed4ae8e4ad7f91a901449ff.tar.xz
germ-b0950591e869d2ffeed4ae8e4ad7f91a901449ff.zip
refactor: optimise return types
-rw-r--r--crates/germ/src/meta.rs4
-rw-r--r--crates/germ/src/request/response.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/germ/src/meta.rs b/crates/germ/src/meta.rs
index 05ca817..2a210a0 100644
--- a/crates/germ/src/meta.rs
+++ b/crates/germ/src/meta.rs
@@ -16,7 +16,7 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::collections::HashMap;
+use std::{borrow::Cow, collections::HashMap};
/// Structure-ize a Gemini response's meta section into it's mime type and it's
/// parameters.
@@ -116,7 +116,7 @@ impl Meta {
/// );
/// ```
#[must_use]
- pub fn mime(&self) -> &str { &self.mime }
+ pub fn mime(&self) -> Cow<'_, str> { Cow::Borrowed(&self.mime) }
/// Obtain mutable access to the mime of the `Meta`
///
diff --git a/crates/germ/src/request/response.rs b/crates/germ/src/request/response.rs
index 9b508f1..dd76e92 100644
--- a/crates/germ/src/request/response.rs
+++ b/crates/germ/src/request/response.rs
@@ -16,6 +16,8 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+use std::borrow::Cow;
+
use rustls::SupportedCipherSuite;
use crate::request::Status;
@@ -59,7 +61,7 @@ impl Response {
pub const fn status(&self) -> &Status { &self.status }
#[must_use]
- pub fn meta(&self) -> &str { &self.meta }
+ pub fn meta(&self) -> Cow<'_, str> { Cow::Borrowed(&self.meta) }
#[must_use]
pub const fn content(&self) -> &Option<String> { &self.content }