From 2e0a1ae3efc3e0cf6281f88d23bbd1309a567c51 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 3 Dec 2024 18:33:26 +0200 Subject: [PATCH] update value preparation, add comments --- src/line/list.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/line/list.rs b/src/line/list.rs index 4c4d93f..39f6c82 100644 --- a/src/line/list.rs +++ b/src/line/list.rs @@ -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 { // Parse line let regex = Regex::split_simple( @@ -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 }) } }