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]] [[package]]
name = "dalet" name = "dalet"
version = "1.0.0-pre6" version = "1.0.0-pre7"
dependencies = [ dependencies = [
"bincode", "bincode",
"clap", "clap",

View file

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

View file

@ -1,5 +1,5 @@
use crate::typed::{ use crate::typed::{
Body, Hl, NNBody, Body, Hl,
Tag::{self, *}, Tag::{self, *},
}; };
@ -8,7 +8,7 @@ pub enum GemTextParseError {
InvalidLink, 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 page: Vec<Tag> = Vec::new();
let mut preformatted = false; let mut preformatted = false;
let mut preformatted_text: Vec<String> = Vec::new(); let mut preformatted_text: Vec<String> = Vec::new();

View file

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

View file

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