mirror of
https://github.com/typst/typst
synced 2025-06-28 16:22:53 +08:00
Simplify some paths
This commit is contained in:
parent
d93ed1b3d8
commit
010084e2d6
@ -738,14 +738,12 @@ impl Array {
|
|||||||
vec.make_mut().sort_by(|a, b| {
|
vec.make_mut().sort_by(|a, b| {
|
||||||
// Until we get `try` blocks :)
|
// Until we get `try` blocks :)
|
||||||
match (key_of(a.clone()), key_of(b.clone())) {
|
match (key_of(a.clone()), key_of(b.clone())) {
|
||||||
(Ok(a), Ok(b)) => {
|
(Ok(a), Ok(b)) => super::ops::compare(&a, &b).unwrap_or_else(|err| {
|
||||||
typst::eval::ops::compare(&a, &b).unwrap_or_else(|err| {
|
|
||||||
if result.is_ok() {
|
if result.is_ok() {
|
||||||
result = Err(err).at(span);
|
result = Err(err).at(span);
|
||||||
}
|
}
|
||||||
Ordering::Equal
|
Ordering::Equal
|
||||||
})
|
}),
|
||||||
}
|
|
||||||
(Err(e), _) | (_, Err(e)) => {
|
(Err(e), _) | (_, Err(e)) => {
|
||||||
if result.is_ok() {
|
if result.is_ok() {
|
||||||
result = Err(e);
|
result = Err(e);
|
||||||
@ -794,7 +792,7 @@ impl Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for second in out.iter() {
|
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;
|
continue 'outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ pub trait Reflect {
|
|||||||
/// Produce an error message for an inacceptable value.
|
/// Produce an error message for an inacceptable value.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use typst::eval::{Int, Reflect, Value};
|
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// <Int as Reflect>::error(Value::None),
|
/// <Int as Reflect>::error(Value::None),
|
||||||
/// "expected integer, found none",
|
/// "expected integer, found none",
|
||||||
|
@ -9,13 +9,12 @@ use serde::de::value::{MapAccessDeserializer, SeqAccessDeserializer};
|
|||||||
use serde::de::{Error, MapAccess, SeqAccess, Visitor};
|
use serde::de::{Error, MapAccess, SeqAccess, Visitor};
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use siphasher::sip128::{Hasher128, SipHasher13};
|
use siphasher::sip128::{Hasher128, SipHasher13};
|
||||||
use typst::eval::Duration;
|
|
||||||
|
|
||||||
use super::repr::{format_float, format_int_with_base};
|
use super::repr::{format_float, format_int_with_base};
|
||||||
use super::{
|
use super::{
|
||||||
fields, ops, Args, Array, AutoValue, Bytes, CastInfo, Content, Dict, FromValue, Func,
|
fields, ops, Args, Array, AutoValue, Bytes, CastInfo, Content, Dict, Duration,
|
||||||
IntoValue, Module, NativeType, NoneValue, Plugin, Reflect, Repr, Scope, Str, Symbol,
|
FromValue, Func, IntoValue, Module, NativeType, NoneValue, Plugin, Reflect, Repr,
|
||||||
Type, Version,
|
Scope, Str, Symbol, Type, Version,
|
||||||
};
|
};
|
||||||
use crate::diag::StrResult;
|
use crate::diag::StrResult;
|
||||||
use crate::eval::{item, Datetime};
|
use crate::eval::{item, Datetime};
|
||||||
|
@ -219,7 +219,7 @@ pub trait NativeElement: Debug + Repr + Construct + Set + Send + Sync + 'static
|
|||||||
fn set_label(&mut self, label: Label);
|
fn set_label(&mut self, label: Label);
|
||||||
|
|
||||||
/// Set the element's label.
|
/// Set the element's label.
|
||||||
fn labelled(mut self, label: ::typst::model::Label) -> Self
|
fn labelled(mut self, label: Label) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
|
@ -26,12 +26,12 @@ macro_rules! __select_where {
|
|||||||
let mut fields = ::smallvec::SmallVec::new();
|
let mut fields = ::smallvec::SmallVec::new();
|
||||||
$(
|
$(
|
||||||
fields.push((
|
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),
|
$crate::eval::IntoValue::into_value($value),
|
||||||
));
|
));
|
||||||
)*
|
)*
|
||||||
::typst::model::Selector::Elem(
|
$crate::model::Selector::Elem(
|
||||||
<$ty as ::typst::model::NativeElement>::elem(),
|
<$ty as $crate::model::NativeElement>::elem(),
|
||||||
Some(fields),
|
Some(fields),
|
||||||
)
|
)
|
||||||
}};
|
}};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user