Do as Dolores says

This commit is contained in:
Laurenz 2020-08-27 21:47:26 +02:00
parent 37835e4d8e
commit 2a92428ff6
4 changed files with 15 additions and 17 deletions

View File

@ -132,9 +132,7 @@ impl PartialEq for Value {
(Color(a), Color(b)) => a == b,
(Table(a), Table(b)) => a == b,
(Tree(a), Tree(b)) => a == b,
(Func(a), Func(b)) => {
a.as_ref() as *const _ == b.as_ref() as *const _
}
(Func(a), Func(b)) => Rc::ptr_eq(a, b),
(Commands(a), Commands(b)) => a == b,
_ => false,
}
@ -202,7 +200,7 @@ impl TableValue {
/// there is any.
///
/// Generates an error if the key exists but the value does not match.
pub fn take_key<'a, T>(&mut self, key: &str, f: &mut Feedback) -> Option<T>
pub fn take_key<T>(&mut self, key: &str, f: &mut Feedback) -> Option<T>
where
T: TryFromValue,
{

View File

@ -14,7 +14,7 @@ use tide::{PdfWriter, Rect, Ref, Trailer, Version};
use ttf_parser::{name_id, GlyphId};
use crate::layout::elements::LayoutElement;
use crate::layout::{BoxLayout, MultiLayout};
use crate::layout::BoxLayout;
use crate::length::Length;
use crate::SharedFontLoader;
@ -27,7 +27,7 @@ use crate::SharedFontLoader;
/// The raw _PDF_ is written into the `target` writable, returning the number of
/// bytes written.
pub fn export<W: Write>(
layout: &MultiLayout,
layout: &[BoxLayout],
loader: &SharedFontLoader,
target: W,
) -> io::Result<usize> {
@ -36,7 +36,7 @@ pub fn export<W: Write>(
struct PdfExporter<'a, W: Write> {
writer: PdfWriter<W>,
layouts: &'a MultiLayout,
layouts: &'a [BoxLayout],
loader: &'a SharedFontLoader,
/// We need to know exactly which indirect reference id will be used for
/// which objects up-front to correctly declare the document catalogue, page
@ -60,7 +60,7 @@ const NUM_OBJECTS_PER_FONT: u32 = 5;
impl<'a, W: Write> PdfExporter<'a, W> {
fn new(
layouts: &'a MultiLayout,
layouts: &'a [BoxLayout],
loader: &'a SharedFontLoader,
target: W,
) -> io::Result<Self> {
@ -289,7 +289,7 @@ impl<'a, W: Write> PdfExporter<'a, W> {
/// Assigns a new PDF-internal index to each used face and returns two mappings:
/// - Forwards from the old face ids to the new pdf indices (hash map)
/// - Backwards from the pdf indices to the old face ids (vec)
fn remap_fonts(layouts: &MultiLayout) -> (HashMap<FaceId, usize>, Vec<FaceId>) {
fn remap_fonts(layouts: &[BoxLayout]) -> (HashMap<FaceId, usize>, Vec<FaceId>) {
let mut to_pdf = HashMap::new();
let mut to_layout = vec![];

View File

@ -67,7 +67,7 @@ impl Parser<'_> {
}
Token::LeftBracket => {
self.parse_bracket_call(false).map(|c| SyntaxNode::Call(c))
self.parse_bracket_call(false).map(SyntaxNode::Call)
}
Token::Star => self.with_span(SyntaxNode::ToggleBolder),
@ -143,7 +143,7 @@ impl Parser<'_> {
let (has_chained_child, end) = if self.peek().is_some() {
let item = self.parse_bracket_call(true);
let span = item.span;
let t = vec![item.map(|f| SyntaxNode::Call(f))];
let t = vec![item.map(SyntaxNode::Call)];
args.push(SpannedEntry::val(Spanned::new(Expr::Tree(t), span)));
(true, span.end)
} else {
@ -203,10 +203,10 @@ impl Parser<'_> {
Some(Token::LeftParen) => {
let call = self.parse_paren_call(ident);
(None, call.map(|c| Expr::Call(c)))
(None, call.map(Expr::Call))
}
_ => (None, ident.map(|id| Expr::Ident(id)))
_ => (None, ident.map(Expr::Ident))
}
} else {
(None, try_or!(self.parse_expr(), {
@ -316,9 +316,9 @@ impl Parser<'_> {
self.eat();
self.skip_white();
if self.check(Token::LeftParen) {
self.parse_paren_call(name).map(|call| Expr::Call(call))
self.parse_paren_call(name).map(Expr::Call)
} else {
name.map(|id| Expr::Ident(id))
name.map(Expr::Ident)
}
}
@ -377,7 +377,7 @@ impl Parser<'_> {
// This is a bracketed function call.
Token::LeftBracket => {
let call = self.parse_bracket_call(false);
let tree = vec![call.map(|c| SyntaxNode::Call(c))];
let tree = vec![call.map(SyntaxNode::Call)];
Spanned::new(Expr::Tree(tree), span)
}

View File

@ -478,7 +478,7 @@ pub fn is_identifier(string: &str) -> bool {
_ => return false,
}
while let Some(c) = chars.next() {
for c in chars {
match c {
c if UnicodeXID::is_xid_continue(c) || is_extra_allowed(c) => {}
_ => return false,