cargo fix --edition & cargo fmt

parent c53e8f47
Pipeline #2112 passed with stages
in 18 minutes and 26 seconds
......@@ -73,7 +73,8 @@ lazy_static! {
include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf") as &[u8],
include_bytes!("../fonts/dejavu/DejaVuSansMono.ttf") as &[u8],
include_bytes!("../fonts/opensans/OpenSans-Italic.ttf") as &[u8],
].into_iter()
]
.into_iter()
.map(|bytes| Font::from_bytes(bytes).unwrap())
.collect();
}
......
......@@ -71,8 +71,8 @@ fn main() -> Result<(), Box<Error>> {
.build();
let program = program!(
&display,
140 => {
&display,
140 => {
vertex: "
#version 140
......@@ -101,7 +101,7 @@ fn main() -> Result<(), Box<Error>> {
f_colour = v_colour * vec4(1.0, 1.0, 1.0, texture(tex, v_tex_coords).r);
}
"
})?;
})?;
let cache_tex = glium::texture::Texture2d::with_format(
&display,
glium::texture::RawImage2d {
......@@ -152,9 +152,11 @@ You can also try resizing this window."
}
_ => (),
},
WindowEvent::ReceivedCharacter(c) => if c != '\u{7f}' && c != '\u{8}' {
text.push(c);
},
WindowEvent::ReceivedCharacter(c) => {
if c != '\u{7f}' && c != '\u{8}' {
text.push(c);
}
}
_ => {}
}
}
......@@ -254,7 +256,8 @@ You can also try resizing this window."
} else {
arrayvec::ArrayVec::new()
}
}).collect();
})
.collect();
glium::VertexBuffer::new(&display, &vertices)?
};
......
......@@ -8,7 +8,8 @@ fn main() {
let collection = FontCollection::from_bytes(font_data as &[u8]).unwrap_or_else(|e| {
panic!("error constructing a FontCollection from bytes: {}", e);
});
let font = collection.into_font() // only succeeds if collection consists of one font
let font = collection
.into_font() // only succeeds if collection consists of one font
.unwrap_or_else(|e| {
panic!("error turning FontCollection into a Font: {}", e);
});
......
......@@ -304,11 +304,13 @@ impl RealQuadraticSolution {
pub fn in_order(self) -> RealQuadraticSolution {
use self::RealQuadraticSolution::*;
match self {
Two(x, y) => if x < y {
Two(x, y)
} else {
Two(y, x)
},
Two(x, y) => {
if x < y {
Two(x, y)
} else {
Two(y, x)
}
}
other => other,
}
}
......
......@@ -824,7 +824,8 @@ impl<'font> Cache<'font> {
}
}
}
}).unwrap();
})
.unwrap();
} else {
// single thread rasterization
for (tex_coords, glyph) in draw_and_upload {
......@@ -1048,7 +1049,8 @@ mod test {
position_tolerance: 0.3,
pad_glyphs: false,
multithread: false,
}.build();
}
.build();
let to_builder: CacheBuilder = cache.to_builder();
......@@ -1071,7 +1073,8 @@ mod test {
let font = Font::from_bytes(
include_bytes!("../fonts/wqy-microhei/WenQuanYiMicroHei.ttf") as &[u8],
).unwrap();
)
.unwrap();
cache.queue_glyph(
0,
font.glyph('l')
......
......@@ -117,7 +117,7 @@ mod rasterizer;
#[cfg(feature = "gpu_cache")]
pub mod gpu_cache;
pub use geometry::{point, vector, Curve, Line, Point, Rect, Vector};
pub use crate::geometry::{point, vector, Curve, Line, Point, Rect, Vector};
use stb_truetype as tt;
use std::fmt;
use std::sync::Arc;
......@@ -411,7 +411,7 @@ impl Scale {
pub trait IntoGlyphId {
/// Convert `self` into a `GlyphId`, consulting the index map of `font` if
/// necessary.
fn into_glyph_id(self, &Font) -> GlyphId;
fn into_glyph_id(self, _: &Font) -> GlyphId;
}
impl IntoGlyphId for char {
fn into_glyph_id(self, font: &Font) -> GlyphId {
......@@ -860,7 +860,8 @@ impl<'a> ScaledGlyph<'a> {
match self.g.inner {
GlyphInner::Proxy(ref font, id) => font.info.get_glyph_shape(id),
GlyphInner::Shared(ref data) => data.shape.clone(),
}.map(|shape| {
}
.map(|shape| {
let mut result = Vec::new();
let mut current = Vec::new();
let mut last = point(0.0, 0.0);
......@@ -995,7 +996,7 @@ impl<'a> PositionedGlyph<'a> {
/// }
/// ```
pub fn draw<O: FnMut(u32, u32, f32)>(&self, o: O) {
use geometry::{Curve, Line};
use crate::geometry::{Curve, Line};
use stb_truetype::VertexType;
let shape = match self.sg.g.inner {
GlyphInner::Proxy(ref font, id) => {
......
use crate::geometry::*;
use arrayvec;
use geometry::*;
use ordered_float::OrderedFloat;
trait SliceUp: Sized {
......@@ -48,7 +48,8 @@ impl Iterator for LineSliceIter {
Some(
Some(Line {
p: [p[0] + v * lower_t, p[0] + v * upper_t],
}).into_iter(),
})
.into_iter(),
)
} else {
Some(None.into_iter())
......@@ -95,10 +96,10 @@ struct CurveSliceIter {
impl Iterator for CurveSliceIter {
type Item = CurveIter;
fn next(&mut self) -> Option<Self::Item> {
use crate::geometry::solve_quadratic_real as solve;
use crate::geometry::Cut;
use crate::geometry::RealQuadraticSolution as RQS;
use arrayvec::ArrayVec;
use geometry::solve_quadratic_real as solve;
use geometry::Cut;
use geometry::RealQuadraticSolution as RQS;
if self.i >= self.planes.count {
return None;
}
......@@ -148,14 +149,16 @@ impl Iterator for CurveSliceIter {
// coincident with one plane
result.push(self.curve);
}
(RQS::None, RQS::None) => if self.a == 0.0
&& self.b == 0.0
&& self.c_shift >= lower_d
&& self.c_shift <= upper_d
{
// parallel to planes, inbetween
result.push(self.curve);
},
(RQS::None, RQS::None) => {
if self.a == 0.0
&& self.b == 0.0
&& self.c_shift >= lower_d
&& self.c_shift <= upper_d
{
// parallel to planes, inbetween
result.push(self.curve);
}
}
_ => unreachable!(), // impossible
}
Some(result.into_iter())
......
......@@ -45,7 +45,8 @@ fn render_to_reference_big_biohazard() {
let reference = image::load(
Cursor::new(include_bytes!("reference_big_biohazard.png") as &[u8]),
image::PNG,
).expect("!image::load")
)
.expect("!image::load")
.to_luma_alpha();
assert_eq!(reference.dimensions(), new_image.dimensions());
......@@ -75,7 +76,8 @@ fn render_to_reference_w() {
let reference = image::load(
Cursor::new(include_bytes!("reference_w.png") as &[u8]),
image::PNG,
).expect("!image::load")
)
.expect("!image::load")
.to_luma_alpha();
assert_eq!(reference.dimensions(), new_image.dimensions());
......@@ -105,7 +107,8 @@ fn render_to_reference_iota() {
let reference = image::load(
Cursor::new(include_bytes!("reference_iota.png") as &[u8]),
image::PNG,
).expect("!image::load")
)
.expect("!image::load")
.to_luma_alpha();
assert_eq!(reference.dimensions(), new_image.dimensions());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment