Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector Module #102

Merged
merged 5 commits into from
Mar 25, 2017
Merged

Vector Module #102

merged 5 commits into from
Mar 25, 2017

Conversation

mcdenhoed
Copy link
Collaborator

Self-explanatory. Implements #101.

Copy link
Owner

@johnthagen johnthagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great. Several minor reorderings requested.


use opengl_graphics::GlGraphics;
use piston_window::{Context, UpdateArgs, Size};
use rand;
use piston_window::{Context, UpdateArgs};

pub mod player;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but I try to alphabetize lists in general to keep things easy to scan through and find. Let's do that with the pub mod's here too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these were already out of order before this PR, should I do it in a separate one, or do it in here? Eh, I'll do it in here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's just do it here, but you're right that this was an oversight from (probably me) from before.

@@ -0,0 +1,144 @@
use rand;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the standard grouping for imports: rust-lang/style-team#24 (comment)

Three sections, with one blank line after each:

  • Standard library imports
  • External crate imports
  • Internal imports

So in this instance, rand would be imported after the std::'s and alphabetically after piston_window in the "3rd party" group.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. I had thought that rand was provided by rust, but wasn't in std, and was trying to alphabetize it. I'll move it down.

@@ -6,7 +6,8 @@ use piston_window::{Context, polygon, Size, Transformed, UpdateArgs};
use rand;

use super::super::color;
use super::{Collidable, Drawable, PI_MULT_2, Positioned, Updateable, Vector};
use super::{Collidable, Drawable, PI_MULT_2, Positioned, Updateable};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed for this PR, but I think we should consider ditching all of the super::'s and just use absolute imports for everything.

See: rust-lang/style-team#24 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea.


pub mod player;
pub mod bullet;
pub mod asteroid;
pub mod vector;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vector does not actually need to be pub at this time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


pub mod player;
pub mod bullet;
pub mod asteroid;
pub mod vector;

pub const PI_MULT_2: f64 = 2.0 * PI;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PI_MULT_2 doesn't need to be pub at this time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@johnthagen
Copy link
Owner

Restarting AppVeyor. Seems curl failed?

@johnthagen
Copy link
Owner

To fix AppVeyor we should just replace the curl with ps: Start-FileDownload (this is Windows after all). The only reason I used curl before is that got it in an example.

@@ -2,156 +2,16 @@

use std::f64;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import isn't actually used. (Why doesn't rustc warn about this case?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that is true. Maybe it doesn't care because it's going to be linked into the final executable anyway?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's because we use use std::f64::consts::PI; below. This feels bug report-worthy to me.

Copy link
Owner

@johnthagen johnthagen Mar 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, this program does warn. I wonder if the import checker more globally to your crate?

use std::f64; // warning: unused import: `std::f64`, #[warn(unused_imports)] on by default
use std::f64::consts::PI;

fn main() {
    println!("PI {}", PI);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... wow. It's because you are actually importing the type f64??

use std::f64; // No warning.

fn main() {
    let x: f64 = 0.0;
    println!("{}", x);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnthagen johnthagen mentioned this pull request Mar 23, 2017
@johnthagen johnthagen merged commit 0c7c3cb into master Mar 25, 2017
@johnthagen johnthagen deleted the vector-module branch March 25, 2017 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants