From b0950591e869d2ffeed4ae8e4ad7f91a901449ff Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 16 Apr 2023 02:27:00 +0000 Subject: refactor: optimise return types --- crates/germ/src/meta.rs | 4 ++-- crates/germ/src/request/response.rs | 4 +++- 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 // 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 // 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 { &self.content } -- cgit v1.2.3