Tidy up
This commit is contained in:
parent
5d05c3f68a
commit
9730e785a8
@ -1,7 +1,5 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Debug, Formatter, Write};
|
||||
use std::iter::FromIterator;
|
||||
use std::ops::{Add, AddAssign};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::{self, Debug, Formatter, Write};
|
||||
use std::iter::FromIterator;
|
||||
use std::ops::{Add, AddAssign};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use super::{Dynamic, Value};
|
||||
use crate::diag::StrResult;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashSet;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::iter;
|
||||
use std::ops::Range;
|
||||
|
||||
|
17
src/frame.rs
17
src/frame.rs
@ -127,18 +127,17 @@ impl Frame {
|
||||
|
||||
impl Debug for Frame {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
struct Children<'a>(&'a [(Point, Element)]);
|
||||
|
||||
impl Debug for Children<'_> {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
f.debug_map().entries(self.0.iter().map(|(k, v)| (k, v))).finish()
|
||||
}
|
||||
}
|
||||
|
||||
f.debug_struct("Frame")
|
||||
.field("size", &self.size)
|
||||
.field("baseline", &self.baseline)
|
||||
.field("children", &Children(&self.elements))
|
||||
.field(
|
||||
"children",
|
||||
&crate::util::debug(|f| {
|
||||
f.debug_map()
|
||||
.entries(self.elements.iter().map(|(k, v)| (k, v)))
|
||||
.finish()
|
||||
}),
|
||||
)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ macro_rules! prelude {
|
||||
|
||||
prelude! {
|
||||
pub use std::fmt::{self, Debug, Formatter};
|
||||
pub use std::hash::Hash;
|
||||
pub use std::num::NonZeroUsize;
|
||||
pub use std::sync::Arc;
|
||||
pub use std::hash::Hash;
|
||||
|
||||
pub use typst_macros::class;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! Text shaping and styling.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::ops::{BitXor, Range};
|
||||
|
||||
|
@ -262,10 +262,10 @@ pub fn upper(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
|
||||
|
||||
/// Converts an integer into a roman numeral.
|
||||
///
|
||||
/// Works for integer between 0 and 3,999,999 inclusive, returns None otherwise.
|
||||
/// Adapted from Yann Villessuzanne's roman.rs under the Unlicense, at
|
||||
/// https://github.com/linfir/roman.rs/
|
||||
/// Works for integer between 0 and 3,999,999.
|
||||
pub fn roman(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
|
||||
// Adapted from Yann Villessuzanne's roman.rs under the Unlicense, at
|
||||
// https://github.com/linfir/roman.rs/
|
||||
static PAIRS: &'static [(&'static str, usize)] = &[
|
||||
("M̅", 1000000),
|
||||
("D̅", 500000),
|
||||
@ -292,7 +292,7 @@ pub fn roman(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> {
|
||||
let Spanned { mut v, span } = args.expect("non-negative integer")?;
|
||||
match v {
|
||||
0_usize => return Ok("N".into()),
|
||||
3_999_999 .. => {
|
||||
4_000_000 .. => {
|
||||
bail!(
|
||||
span,
|
||||
"cannot convert integers greater than 3,999,999 to roman numerals"
|
||||
|
@ -9,10 +9,30 @@ pub use mac_roman::decode_mac_roman;
|
||||
|
||||
use std::cell::RefMut;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::ops::Range;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Turn a closure into a struct implementing [`Debug`].
|
||||
pub fn debug<F>(f: F) -> impl Debug
|
||||
where
|
||||
F: Fn(&mut Formatter) -> fmt::Result,
|
||||
{
|
||||
struct Wrapper<F>(F);
|
||||
|
||||
impl<F> Debug for Wrapper<F>
|
||||
where
|
||||
F: Fn(&mut Formatter) -> fmt::Result,
|
||||
{
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
self.0(f)
|
||||
}
|
||||
}
|
||||
|
||||
Wrapper(f)
|
||||
}
|
||||
|
||||
/// Additional methods for strings.
|
||||
pub trait StrExt {
|
||||
/// The number of code units this string would use if it was encoded in
|
||||
|
Loading…
x
Reference in New Issue
Block a user