fix: pass &str instead of String in parse_gemtext

This commit is contained in:
Artemy Egorov 2024-08-04 11:10:43 +03:00
parent f45808fc40
commit 104968f95e
5 changed files with 6 additions and 9 deletions

2
Cargo.lock generated
View file

@ -151,7 +151,7 @@ dependencies = [
[[package]]
name = "dalet"
version = "1.0.0-pre6"
version = "1.0.0-pre7"
dependencies = [
"bincode",
"clap",

View file

@ -1,6 +1,6 @@
[package]
name = "dalet"
version = "1.0.0-pre6"
version = "1.0.0-pre7"
edition = "2021"
authors = ["artegoser"]
license = "MIT"

View file

@ -1,5 +1,5 @@
use crate::typed::{
Body, Hl, NNBody,
Body, Hl,
Tag::{self, *},
};
@ -8,7 +8,7 @@ pub enum GemTextParseError {
InvalidLink,
}
pub fn parse_gemtext(s: String) -> Result<Vec<Tag>, GemTextParseError> {
pub fn parse_gemtext(s: &str) -> Result<Vec<Tag>, GemTextParseError> {
let mut page: Vec<Tag> = Vec::new();
let mut preformatted = false;
let mut preformatted_text: Vec<String> = Vec::new();

View file

@ -1,10 +1,7 @@
use dalet::{
daletl::ToDaletlPage,
daletpack::*,
typed::{
Body, Hl, NNBody, Page, TNArg,
Tag::{self, *},
},
typed::{Hl, Page, TNArg, Tag::*},
};
use flate2::Compression;
use std::io::Write;

View file

@ -4,7 +4,7 @@ use dalet::parsers::gemtext::parse_gemtext;
fn gem_text() {
let text = include_str!("./gemtext.gmi");
let parsed = parse_gemtext(text.to_owned()).unwrap();
let parsed = parse_gemtext(&text).unwrap();
println!("{:#?}", parsed);
}