fix: type in resolve title

This commit is contained in:
Artemy Egorov 2024-08-07 15:23:18 +03:00
parent f3231b52c4
commit 915c5c0a6d
4 changed files with 7 additions and 7 deletions

2
Cargo.lock generated
View file

@ -151,7 +151,7 @@ dependencies = [
[[package]] [[package]]
name = "dalet" name = "dalet"
version = "1.0.0-pre.13" version = "1.0.0-pre.14"
dependencies = [ dependencies = [
"bincode", "bincode",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "dalet" name = "dalet"
version = "1.0.0-pre.13" version = "1.0.0-pre.14"
edition = "2021" edition = "2021"
authors = ["artegoser"] authors = ["artegoser"]
license = "MIT" license = "MIT"

View file

@ -4,23 +4,23 @@ use crate::typed::{
}; };
impl ResolveTitle for Page { impl ResolveTitle for Page {
fn resolve_title(&self) -> Option<&String> { fn resolve_title(&self) -> Option<String> {
resolve_from_tags(&self.data) resolve_from_tags(&self.data)
} }
} }
fn resolve_from_tags(tags: &Vec<Tag>) -> Option<&String> { fn resolve_from_tags(tags: &Vec<Tag>) -> Option<String> {
for tag in tags { for tag in tags {
match tag { match tag {
H(title, level) => { H(title, level) => {
if *level == Hl::One { if *level == Hl::One {
return Some(title); return Some(title.to_owned());
} }
} }
Meta(body, key) => { Meta(body, key) => {
if key == "title" { if key == "title" {
return Some(body); return Some(body.to_owned());
} }
} }

View file

@ -109,5 +109,5 @@ pub enum Hl {
} }
pub trait ResolveTitle { pub trait ResolveTitle {
fn resolve_title(&self) -> Option<&String>; fn resolve_title(&self) -> Option<String>;
} }