Skip to content

Commit

Permalink
update value preparation, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Dec 3, 2024
1 parent 4741365 commit 2e0a1ae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/line/list.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use glib::{Regex, RegexCompileFlags, RegexMatchFlags};

/// [List item](https://geminiprotocol.net/docs/gemtext-specification.gmi#list-items)
pub struct List {
pub value: String,
}

impl List {
/// Parse `Self` from string
pub fn from(line: &str) -> Option<Self> {
// Parse line
let regex = Regex::split_simple(
Expand All @@ -14,12 +16,10 @@ impl List {
RegexMatchFlags::DEFAULT,
);

// Detect value
let value = regex.get(1)?.trim();
// Extract formatted value
let value = regex.get(1)?.trim().to_string();

// Result
Some(Self {
value: String::from(value),
})
Some(Self { value })
}
}

0 comments on commit 2e0a1ae

Please sign in to comment.