Skip to content

Commit 89dcd5a

Browse files
committed
refactor: use SplitCharFromStr
1 parent d862d97 commit 89dcd5a

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ std = []
3636
[dependencies]
3737
derive_more = { version = "1.0.0", default-features = false, features = ["display", "error", "into_iterator"] }
3838
pipe-trait = "0.4.0"
39-
split-first-char = "0.0.0"
39+
split-char-from-str = "0.0.0"
4040

4141
[dev-dependencies]
4242
pretty_assertions = "1.4.1"

src/enclosed/parser.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{ComponentParserInput, ParserConfig, Segment};
22
use crate::{IntoSkipOrFatal, Parse};
33
use derive_more::{Display, Error};
4-
use split_first_char::split_first_char;
4+
use split_char_from_str::SplitCharFromStr;
55

66
/// Parse a template string whose queries are placed between an opening bracket character and a closing bracket character,
77
/// (such as [curly braces](crate::simple_curly_braces)).
@@ -146,7 +146,9 @@ where
146146
return Ok((Segment::Expression(query), rest));
147147
}
148148

149-
let (head, tail) = split_first_char(input).ok_or(ParseError::UnexpectedEndOfInput)?;
149+
let (head, tail) = input
150+
.split_first_char()
151+
.ok_or(ParseError::UnexpectedEndOfInput)?;
150152

151153
if head == self.config.close_bracket {
152154
return Err(ParseError::UnexpectedChar(head));

src/enclosed/simple_escape.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{ComponentParserInput, ParserConfig};
22
use crate::Parse;
33
use derive_more::{Display, Error};
4-
use split_first_char::split_first_char;
4+
use split_char_from_str::SplitCharFromStr;
55

66
pub type ParserInput<'a> = ComponentParserInput<'a>;
77

@@ -25,14 +25,15 @@ impl<'a> Parse<'a, ParserInput<'a>> for Parser {
2525
type Error = Option<ParseError>;
2626

2727
fn parse(&self, input: ParserInput<'a>) -> Result<(Self::Output, &'a str), Self::Error> {
28-
let (head, tail) = split_first_char(input.text).ok_or(None)?;
28+
let (head, tail) = input.text.split_first_char().ok_or(None)?;
2929

3030
if head != '\\' {
3131
return Err(None);
3232
}
3333

34-
let (escape_code, rest) =
35-
split_first_char(tail).ok_or(Some(ParseError::UnexpectedEndOfInput))?;
34+
let (escape_code, rest) = tail
35+
.split_first_char()
36+
.ok_or(Some(ParseError::UnexpectedEndOfInput))?;
3637

3738
let char = escape_bracket(escape_code, input.config)
3839
.or_else(|| make_special_character(escape_code))

src/enclosed/simple_query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::ComponentParserInput;
22
use crate::Parse;
33
use derive_more::{Display, Error};
44
use pipe_trait::Pipe;
5-
use split_first_char::split_first_char;
5+
use split_char_from_str::SplitCharFromStr;
66

77
pub type ParserInput<'a> = ComponentParserInput<'a>;
88

@@ -26,7 +26,7 @@ impl<'a> Parse<'a, ParserInput<'a>> for Parser {
2626
type Error = Option<ParseError>;
2727

2828
fn parse(&self, input: ParserInput<'a>) -> Result<(Self::Output, &'a str), Self::Error> {
29-
let (head, tail) = split_first_char(input.text).ok_or(None)?;
29+
let (head, tail) = input.text.split_first_char().ok_or(None)?;
3030

3131
if head == input.config.close_bracket {
3232
return head.pipe(ParseError::UnexpectedChar).pipe(Some).pipe(Err);

0 commit comments

Comments
 (0)