mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 09:05:32 +00:00
change result data type to &str
This commit is contained in:
parent
7802869d0d
commit
5b751e3c7a
3 changed files with 8 additions and 8 deletions
|
|
@ -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+
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue