Skip to content

Commit 2ec2318

Browse files
authored
Merge pull request #45 from Atul9/cargo-fmt
Format using 'cargo fmt'
2 parents fd4d475 + 8fe476a commit 2ec2318

File tree

10 files changed

+48
-56
lines changed

10 files changed

+48
-56
lines changed

raylib-test/src/audio.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#[cfg(test)]
32
mod audio_test {
4-
use raylib::prelude::*;
53
use crate::tests::*;
4+
use raylib::prelude::*;
65
#[test]
76
fn test_init_audio() {
87
let _ = RaylibAudio::init_audio_device();

raylib-test/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Permission is granted to anyone to use this software for any purpose, including
2323
#![test_runner(crate::tests::test_runner)]
2424
#![allow(dead_code)]
2525
#![doc(
26-
html_logo_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust_256x256.png",
27-
html_favicon_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust.ico"
26+
html_logo_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust_256x256.png",
27+
html_favicon_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust.ico"
2828
)]
2929
#![feature(test)]
3030
extern crate test;

raylib-test/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod core_test {
3-
use raylib::prelude::*;
43
use crate::tests::*;
4+
use raylib::prelude::*;
55
ray_test!(test_screenshot);
66
fn test_screenshot(t: &RaylibThread) {
77
let mut handle = TEST_HANDLE.write().unwrap();

raylib-test/src/models.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#[cfg(test)]
32
mod model_test {
4-
use raylib::prelude::*;
53
use crate::tests::*;
4+
use raylib::prelude::*;
65

76
ray_test!(test_load_model);
87
fn test_load_model(thread: &RaylibThread) {

raylib-test/src/texture.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
#[cfg(test)]
32
mod texture_test {
4-
use raylib::prelude::*;
53
use crate::tests::*;
4+
use raylib::prelude::*;
65
#[test]
76
fn test_image_loading() {
87
let i = Image::load_image("resources/billboard.png").expect("image not found");

raylib/src/core/models.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ impl RaylibHandle {
4747
pub fn load_model_from_mesh(&mut self, _: &RaylibThread, mesh: &Mesh) -> Result<Model, String> {
4848
let m = unsafe { ffi::LoadModelFromMesh(mesh.0) };
4949

50-
if m.meshes.is_null() || m.materials.is_null() || m.bones.is_null() || m.bindPose.is_null() {
51-
return Err("Could not load model from mesh".to_owned())
50+
if m.meshes.is_null() || m.materials.is_null() || m.bones.is_null() || m.bindPose.is_null()
51+
{
52+
return Err("Could not load model from mesh".to_owned());
5253
}
5354

5455
Ok(Model(m))

samples/3d_camera_first_person.rs

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use raylib::prelude::*;
2-
use rand::prelude::*;
31
use arr_macro::arr;
2+
use rand::prelude::*;
3+
use raylib::prelude::*;
44

55
const WINDOW_WIDTH: i32 = 1280;
66
const WINDOW_HEIGHT: i32 = 720;
77

88
struct Column {
99
height: f32,
1010
position: Vector3,
11-
color: Color
11+
color: Color,
1212
}
1313

1414
impl Column {
@@ -20,17 +20,12 @@ impl Column {
2020
height / 2.0,
2121
rng.gen_range(-15.0, 15.0),
2222
);
23-
let color = Color::new(
24-
rng.gen_range(20, 255),
25-
rng.gen_range(10, 55),
26-
30,
27-
255
28-
);
29-
23+
let color = Color::new(rng.gen_range(20, 255), rng.gen_range(10, 55), 30, 255);
24+
3025
Column {
3126
height,
3227
position,
33-
color
28+
color,
3429
}
3530
}
3631
}
@@ -42,10 +37,10 @@ fn main() {
4237
.build();
4338

4439
let mut camera = Camera3D::perspective(
45-
Vector3::new(4.0, 2.0, 4.0),
46-
Vector3::new(0.0, 1.8, 0.0),
47-
Vector3::new(0.0, 1.0, 0.0),
48-
60.0
40+
Vector3::new(4.0, 2.0, 4.0),
41+
Vector3::new(0.0, 1.8, 0.0),
42+
Vector3::new(0.0, 1.0, 0.0),
43+
60.0,
4944
);
5045
let columns: [Column; 20] = arr![Column::create_random(); 20];
5146

@@ -64,29 +59,26 @@ fn main() {
6459
d2.draw_plane(
6560
Vector3::new(0.0, 0.0, 0.0),
6661
Vector2::new(32.0, 32.0),
67-
Color::LIGHTGRAY
68-
);
69-
d2.draw_cube(
70-
Vector3::new(-16.0, 2.5, 0.0),
71-
1.0, 5.0, 32.0, Color::BLUE
72-
);
73-
d2.draw_cube(
74-
Vector3::new(16.0, 2.5, 0.0),
75-
1.0, 5.0, 32.0, Color::LIME
76-
);
77-
d2.draw_cube(
78-
Vector3::new(0.0, 2.5, 16.0),
79-
32.0, 5.0, 1.0, Color::GOLD
62+
Color::LIGHTGRAY,
8063
);
64+
d2.draw_cube(Vector3::new(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, Color::BLUE);
65+
d2.draw_cube(Vector3::new(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, Color::LIME);
66+
d2.draw_cube(Vector3::new(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, Color::GOLD);
8167

8268
for column in columns.into_iter() {
8369
d2.draw_cube(column.position, 2.0, column.height, 2.0, column.color);
8470
d2.draw_cube_wires(column.position, 2.0, column.height, 2.0, Color::MAROON);
85-
};
71+
}
8672
}
8773
d.draw_rectangle(10, 10, 220, 70, Color::SKYBLUE);
8874
d.draw_rectangle_lines(10, 10, 220, 70, Color::BLUE);
89-
d.draw_text("First person camera default controls:", 20, 20, 10, Color::BLACK);
75+
d.draw_text(
76+
"First person camera default controls:",
77+
20,
78+
20,
79+
10,
80+
Color::BLACK,
81+
);
9082
d.draw_text("- Move with keys: W, A, S, D", 40, 40, 10, Color::DARKGRAY);
9183
d.draw_text("- Mouse move to look around", 40, 60, 10, Color::DARKGRAY);
9284
}

samples/rgui_button.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ pub fn main() {
1010

1111
let mut wb = rgui::WindowBox {
1212
bounds: Rectangle::new(64.0, 64.0, 128.0, 72.0),
13-
text: CString::new("Hello World").unwrap()
13+
text: CString::new("Hello World").unwrap(),
1414
};
1515

1616
rl.set_target_fps(200);
1717

1818
let btn = rgui::Button {
1919
bounds: Rectangle::new(72.0, 172.0 + 24.0, 64.0, 16.0),
20-
text: CString::new("Click Me").unwrap()
20+
text: CString::new("Click Me").unwrap(),
2121
};
2222

2323
let mut exit_program = false;
@@ -27,11 +27,15 @@ pub fn main() {
2727
d.clear_background(Color::WHITE);
2828

2929
if let rgui::DrawResult::Bool(b) = d.draw_gui(&wb) {
30-
if b { exit_program = true; }
30+
if b {
31+
exit_program = true;
32+
}
3133
}
3234

3335
if let rgui::DrawResult::Bool(b) = d.draw_gui(&btn) {
34-
if b { wb.bounds.x += 8.0; }
36+
if b {
37+
wb.bounds.x += 8.0;
38+
}
3539
}
3640
}
3741
}

samples/roguelike.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// IMHO Don't write code like this. Use ECS and other methods to have game objects and components.
55
/// Only do this as an exercise.
66
extern crate raylib;
7-
use rand::distributions::{ WeightedIndex };
7+
use rand::distributions::WeightedIndex;
88
use rand::prelude::*;
99
use rand::Rng;
1010
use raylib::prelude::*;
@@ -731,7 +731,7 @@ fn place_objects(room: Rectangle, map: &Map, objects: &mut Vec<Object>, level: u
731731
Item::Fireball,
732732
Item::Confuse,
733733
Item::Sword,
734-
Item::Shield
734+
Item::Shield,
735735
];
736736
let item_weights = [
737737
32,

samples/texture.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ fn main() {
88
let opt = options::Opt::from_args();
99
let (mut rl, thread) = opt.open_window("Texture");
1010
let (_w, _h) = (opt.width, opt.height);
11-
let i =
12-
Image::load_image("static/billboard.png").expect("could not load image billboard");
13-
let _ = rl
14-
.load_texture(&thread, "static/billboard.png")
15-
.expect("could not load texture billboard");
16-
let t = rl
17-
.load_texture_from_image(&thread, &i)
18-
.expect("could not load texture from image");
19-
11+
let i = Image::load_image("static/billboard.png").expect("could not load image billboard");
12+
let _ = rl
13+
.load_texture(&thread, "static/billboard.png")
14+
.expect("could not load texture billboard");
15+
let t = rl
16+
.load_texture_from_image(&thread, &i)
17+
.expect("could not load texture from image");
2018

2119
rl.set_target_fps(60);
2220
while !rl.window_should_close() {

0 commit comments

Comments
 (0)