Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
icefoxen committed Jul 2, 2019
1 parent 409ee9c commit 196e2c6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 26 deletions.
4 changes: 1 addition & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use std::path::PathBuf;
fn main() {
let mut mdbook_files = skeptic::markdown_files_of_directory("docs/guides/");

let other_files: Vec<PathBuf> = vec![
"README.md".into(),
];
let other_files: Vec<PathBuf> = vec!["README.md".into()];
mdbook_files.extend(other_files);
skeptic::generate_doc_tests(&mdbook_files);
}
2 changes: 1 addition & 1 deletion examples/01_super_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn main() -> GameResult {
} else {
path::PathBuf::from("./resources")
};

let cb = ggez::ContextBuilder::new("bunnymark", "ggez").add_resource_path(resource_dir);
let (ctx, event_loop) = &mut cb.build()?;
let state = &mut MainState::new(ctx)?;
Expand Down
2 changes: 1 addition & 1 deletion examples/05_astroblasto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! The idea is that this game is simple but still
//! non-trivial enough to be interesting.
use rand;
use ggez;
use ggez::audio;
use ggez::audio::SoundSource;
Expand All @@ -12,6 +11,7 @@ use ggez::graphics;
use ggez::nalgebra as na;
use ggez::timer;
use ggez::{Context, ContextBuilder, GameResult};
use rand;

use std::env;
use std::path;
Expand Down
33 changes: 20 additions & 13 deletions examples/bunnymark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use std::env;
use std::path;

use nalgebra as na;
use rand::rngs::ThreadRng;
use rand::{self, Rng};
use nalgebra as na;

use ggez::*;
use ggez::graphics::{Color, Image, spritebatch::SpriteBatch};
use ggez::graphics::{spritebatch::SpriteBatch, Color, Image};
use ggez::Context;
use ggez::*;

// NOTE: Using a high number here yields worse performance than adding more bunnies over
// time - I think this is due to all of the RNG being run on the same tick...
Expand Down Expand Up @@ -116,12 +116,12 @@ impl event::EventHandler for GameState {
if self.batched_drawing {
self.bunnybatch.clear();
for bunny in &self.bunnies {
self.bunnybatch.add((bunny.position, ));
self.bunnybatch.add((bunny.position,));
}
graphics::draw(ctx, &self.bunnybatch, (na::Point2::new(0.0, 0.0), ))?;
graphics::draw(ctx, &self.bunnybatch, (na::Point2::new(0.0, 0.0),))?;
} else {
for bunny in &self.bunnies {
graphics::draw(ctx, &self.texture, (bunny.position, ))?;
graphics::draw(ctx, &self.texture, (bunny.position,))?;
}
}

Expand All @@ -139,25 +139,32 @@ impl event::EventHandler for GameState {
Ok(())
}

fn key_down_event(&mut self, _ctx: &mut Context,
keycode: event::KeyCode, _keymods: event::KeyMods, _repeat: bool) {
fn key_down_event(
&mut self,
_ctx: &mut Context,
keycode: event::KeyCode,
_keymods: event::KeyMods,
_repeat: bool,
) {
if keycode == event::KeyCode::Space {
self.batched_drawing = !self.batched_drawing;
}
}

fn mouse_button_down_event(&mut self, _ctx: &mut Context,
button: input::mouse::MouseButton,
_x: f32,
_y: f32) {
fn mouse_button_down_event(
&mut self,
_ctx: &mut Context,
button: input::mouse::MouseButton,
_x: f32,
_y: f32,
) {
if button == input::mouse::MouseButton::Left && self.click_timer == 0 {
for _ in 0..INITIAL_BUNNIES {
self.bunnies.push(Bunny::new(&mut self.rng));
}
self.click_timer = 10;
}
}

}

fn main() -> GameResult {
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl Context {
self.mouse_context
.set_last_delta(Point2::new(x as f32, y as f32));
}
},
}

_ => (),
};
Expand Down
13 changes: 9 additions & 4 deletions src/graphics/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ impl MeshBuilder {
P: Into<mint::Point2<f32>> + Clone,
{
if points.len() < 2 {
return Err(GameError::LyonError("MeshBuilder::polyline() got a list of < 2 points".to_string()))
return Err(GameError::LyonError(
"MeshBuilder::polyline() got a list of < 2 points".to_string(),
));
}

self.polyline_inner(mode, points, false, color)
Expand All @@ -207,7 +209,9 @@ impl MeshBuilder {
P: Into<mint::Point2<f32>> + Clone,
{
if points.len() < 3 {
return Err(GameError::LyonError("MeshBuilder::polygon() got a list of < 3 points".to_string()))
return Err(GameError::LyonError(
"MeshBuilder::polygon() got a list of < 3 points".to_string(),
));
}

self.polyline_inner(mode, points, true, color)
Expand Down Expand Up @@ -366,7 +370,6 @@ impl MeshBuilder {
return Err(GameError::LyonError(msg));
}


let (vbuf, slice) = ctx
.gfx_context
.factory
Expand Down Expand Up @@ -506,7 +509,9 @@ impl Mesh {
P: Into<mint::Point2<f32>> + Clone,
{
if points.len() < 3 {
return Err(GameError::LyonError("Mesh::new_polygon() got a list of < 3 points".to_string()))
return Err(GameError::LyonError(
"Mesh::new_polygon() got a list of < 3 points".to_string(),
));
}
let mut mb = MeshBuilder::new();
let _ = mb.polygon(mode, points, color);
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//! struct MyGame {
//! // Your state here...
//! }
//!
//!
//! impl MyGame {
//! pub fn new(_ctx: &mut Context) -> MyGame {
//! // Load/create resources such as images here.
Expand All @@ -77,7 +77,7 @@
//! graphics::present(ctx)
//! }
//! }
//!
//!
//! ```
#![deny(missing_docs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ fn test_transform_stack_order() {
let m2: crate::nalgebra::Matrix4<f32> = t2.into();
assert_eq!(res, m2 * m1);
}

0 comments on commit 196e2c6

Please sign in to comment.