change result data type to &str

This commit is contained in:
yggverse 2025-03-16 15:53:24 +02:00
parent 7802869d0d
commit 5b751e3c7a
3 changed files with 8 additions and 8 deletions

View file

@ -37,7 +37,7 @@ impl Header {
} }
pub trait Gemtext { pub trait Gemtext {
/// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value from `Self` /// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value for `Self`
fn as_value(&self) -> Option<&Self>; fn as_value(&self) -> Option<&Self>;
/// Convert `Self` to `Level` /// Convert `Self` to `Level`
fn to_level(&self) -> Option<Level>; fn to_level(&self) -> Option<Level>;
@ -46,7 +46,7 @@ pub trait Gemtext {
} }
impl Gemtext for str { impl Gemtext for str {
fn as_value(&self) -> Option<&Self> { fn as_value(&self) -> Option<&str> {
if let Some(h3) = self.strip_prefix(TAG_H3) { if let Some(h3) = self.strip_prefix(TAG_H3) {
if h3.trim_start().starts_with(TAG_H1) { if h3.trim_start().starts_with(TAG_H1) {
return None; // H4+ return None; // H4+

View file

@ -25,14 +25,14 @@ impl List {
} }
pub trait Gemtext { pub trait Gemtext {
/// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value from `Self` /// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value for `Self`
fn as_value(&self) -> Option<&Self>; fn as_value(&self) -> Option<&str>;
/// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line /// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line
fn to_source(&self) -> String; fn to_source(&self) -> String;
} }
impl Gemtext for str { impl Gemtext for str {
fn as_value(&self) -> Option<&Self> { fn as_value(&self) -> Option<&str> {
self.strip_prefix(TAG).map(|s| s.trim()) self.strip_prefix(TAG).map(|s| s.trim())
} }
fn to_source(&self) -> String { fn to_source(&self) -> String {

View file

@ -25,14 +25,14 @@ impl Quote {
} }
pub trait Gemtext { pub trait Gemtext {
/// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value from `Self` /// Get [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) value for `Self`
fn as_value(&self) -> Option<&Self>; fn as_value(&self) -> Option<&str>;
/// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line /// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line
fn to_source(&self) -> String; fn to_source(&self) -> String;
} }
impl Gemtext for str { impl Gemtext for str {
fn as_value(&self) -> Option<&Self> { fn as_value(&self) -> Option<&str> {
self.strip_prefix(TAG).map(|s| s.trim()) self.strip_prefix(TAG).map(|s| s.trim())
} }
fn to_source(&self) -> String { fn to_source(&self) -> String {