From 010084e2d6d4c766bac9cc751ee6940cd3278695 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 10 Nov 2023 12:01:00 +0100 Subject: [PATCH] Simplify some paths --- crates/typst/src/eval/array.rs | 16 +++++++--------- crates/typst/src/eval/cast.rs | 1 - crates/typst/src/eval/value.rs | 7 +++---- crates/typst/src/model/element.rs | 2 +- crates/typst/src/model/selector.rs | 6 +++--- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/crates/typst/src/eval/array.rs b/crates/typst/src/eval/array.rs index 497f91b5f..55e0cc699 100644 --- a/crates/typst/src/eval/array.rs +++ b/crates/typst/src/eval/array.rs @@ -738,14 +738,12 @@ impl Array { vec.make_mut().sort_by(|a, b| { // Until we get `try` blocks :) match (key_of(a.clone()), key_of(b.clone())) { - (Ok(a), Ok(b)) => { - typst::eval::ops::compare(&a, &b).unwrap_or_else(|err| { - if result.is_ok() { - result = Err(err).at(span); - } - Ordering::Equal - }) - } + (Ok(a), Ok(b)) => super::ops::compare(&a, &b).unwrap_or_else(|err| { + if result.is_ok() { + result = Err(err).at(span); + } + Ordering::Equal + }), (Err(e), _) | (_, Err(e)) => { if result.is_ok() { result = Err(e); @@ -794,7 +792,7 @@ impl Array { } for second in out.iter() { - if typst::eval::ops::equal(&key, &key_of(second.clone())?) { + if super::ops::equal(&key, &key_of(second.clone())?) { continue 'outer; } } diff --git a/crates/typst/src/eval/cast.rs b/crates/typst/src/eval/cast.rs index 4bb5b6af1..0ba8535d1 100644 --- a/crates/typst/src/eval/cast.rs +++ b/crates/typst/src/eval/cast.rs @@ -45,7 +45,6 @@ pub trait Reflect { /// Produce an error message for an inacceptable value. /// /// ``` - /// # use typst::eval::{Int, Reflect, Value}; /// assert_eq!( /// ::error(Value::None), /// "expected integer, found none", diff --git a/crates/typst/src/eval/value.rs b/crates/typst/src/eval/value.rs index a0b2645c9..d40214156 100644 --- a/crates/typst/src/eval/value.rs +++ b/crates/typst/src/eval/value.rs @@ -9,13 +9,12 @@ use serde::de::value::{MapAccessDeserializer, SeqAccessDeserializer}; use serde::de::{Error, MapAccess, SeqAccess, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use siphasher::sip128::{Hasher128, SipHasher13}; -use typst::eval::Duration; use super::repr::{format_float, format_int_with_base}; use super::{ - fields, ops, Args, Array, AutoValue, Bytes, CastInfo, Content, Dict, FromValue, Func, - IntoValue, Module, NativeType, NoneValue, Plugin, Reflect, Repr, Scope, Str, Symbol, - Type, Version, + fields, ops, Args, Array, AutoValue, Bytes, CastInfo, Content, Dict, Duration, + FromValue, Func, IntoValue, Module, NativeType, NoneValue, Plugin, Reflect, Repr, + Scope, Str, Symbol, Type, Version, }; use crate::diag::StrResult; use crate::eval::{item, Datetime}; diff --git a/crates/typst/src/model/element.rs b/crates/typst/src/model/element.rs index 4426ff319..7551f83b2 100644 --- a/crates/typst/src/model/element.rs +++ b/crates/typst/src/model/element.rs @@ -219,7 +219,7 @@ pub trait NativeElement: Debug + Repr + Construct + Set + Send + Sync + 'static fn set_label(&mut self, label: Label); /// Set the element's label. - fn labelled(mut self, label: ::typst::model::Label) -> Self + fn labelled(mut self, label: Label) -> Self where Self: Sized, { diff --git a/crates/typst/src/model/selector.rs b/crates/typst/src/model/selector.rs index c71569e6c..2159d84e1 100644 --- a/crates/typst/src/model/selector.rs +++ b/crates/typst/src/model/selector.rs @@ -26,12 +26,12 @@ macro_rules! __select_where { let mut fields = ::smallvec::SmallVec::new(); $( fields.push(( - <$ty as ::typst::model::ElementFields>::Fields::$field as u8, + <$ty as $crate::model::ElementFields>::Fields::$field as u8, $crate::eval::IntoValue::into_value($value), )); )* - ::typst::model::Selector::Elem( - <$ty as ::typst::model::NativeElement>::elem(), + $crate::model::Selector::Elem( + <$ty as $crate::model::NativeElement>::elem(), Some(fields), ) }};