mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2024-11-23 09:06:22 +03:00
fix: type in resolve title
This commit is contained in:
parent
f3231b52c4
commit
915c5c0a6d
4 changed files with 7 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -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",
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue