summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-27 21:47:26 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-27 21:47:26 +0200
commit2a92428ff6986d8e564b7c223f3d0c5ca0eacaf1 (patch)
tree4545b5b598aa95cb23b6737884b5b6e2ee8c0a33 /src
parent37835e4d8e5029c857ba4f11b8c2a09563423746 (diff)
Do as Dolores says ⚡
Diffstat (limited to 'src')
-rw-r--r--src/compute/value.rs6
-rw-r--r--src/export/pdf.rs10
-rw-r--r--src/syntax/parsing.rs14
-rw-r--r--src/syntax/tokens.rs2
4 files changed, 15 insertions, 17 deletions
diff --git a/src/compute/value.rs b/src/compute/value.rs
index c11a3d31..bac6396d 100644
--- a/src/compute/value.rs
+++ b/src/compute/value.rs
@@ -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,
{
diff --git a/src/export/pdf.rs b/src/export/pdf.rs
index cd417a9c..e8220b54 100644
--- a/src/export/pdf.rs
+++ b/src/export/pdf.rs
@@ -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![];
diff --git a/src/syntax/parsing.rs b/src/syntax/parsing.rs
index 96db687d..29a9d788 100644
--- a/src/syntax/parsing.rs
+++ b/src/syntax/parsing.rs
@@ -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)
}
diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs
index 24d8ecfb..1dcf9022 100644
--- a/src/syntax/tokens.rs
+++ b/src/syntax/tokens.rs
@@ -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,