Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo fix and smaller refactorings #650

Merged
merged 7 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion minijinja-py/src/typeconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub fn to_python_args<'py>(

if callback
.getattr("__minijinja_pass_state__")
.map_or(false, |x| x.is_truthy().unwrap_or(false))
.is_ok_and(|x| x.is_truthy().unwrap_or(false))
{
py_args.push(Bound::new(py, StateRef)?.to_object(py));
}
Expand Down
10 changes: 2 additions & 8 deletions minijinja/src/compiler/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ fn find_start_marker_memchr(a: &str) -> Option<(usize, StartMarker, usize, White
let bytes = a.as_bytes();
let mut offset = 0;
loop {
let idx = match memchr(&bytes[offset..], b'{') {
Some(idx) => idx,
None => return None,
};
let idx = some!(memchr(&bytes[offset..], b'{'));
let marker = match bytes.get(offset + idx + 1).copied() {
Some(b'{') => StartMarker::Variable,
Some(b'%') => StartMarker::Block,
Expand Down Expand Up @@ -530,10 +527,7 @@ impl<'s> Tokenizer<'s> {
let s = self.advance(str_len + 2);
Ok(if has_escapes {
(
Token::String(match unescape(&s[1..s.len() - 1]) {
Ok(unescaped) => unescaped,
Err(err) => return Err(err),
}),
Token::String(ok!(unescape(&s[1..s.len() - 1]))),
self.span(old_loc),
)
} else {
Expand Down
4 changes: 2 additions & 2 deletions minijinja/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<T: Copy> Clone for Packed<T> {

/// Max size of a small str.
///
/// Logic: Value is 24 bytes. 1 byte is for the disciminant. One byte is
/// Logic: Value is 24 bytes. 1 byte is for the discriminant. One byte is
/// needed for the small str length.
const SMALL_STR_CAP: usize = 22;

Expand Down Expand Up @@ -539,7 +539,7 @@ impl PartialEq for Value {
if !a.try_iter_pairs().map_or(false, |mut ak| {
ak.all(|(k, v1)| {
a_count += 1;
b.get_value(&k).map_or(false, |v2| v1 == v2)
b.get_value(&k) == Some(v1)
})
}) {
return false;
Expand Down