Skip to content

Commit

Permalink
Changes to version 1.29.1 (b801ae664 2018-09-20)
Browse files Browse the repository at this point in the history
The use of literal pattern matching on floating points has been
deprecated. It currently produces a warning, but will eventually
cause a compilation error.

See: rust-lang/rust#41620
  • Loading branch information
BlockBlazeDev committed Oct 1, 2018
1 parent 783f8e7 commit a69a38d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: rust
rust: 1.13.0
rust: 1.29.1
env:
global:
- secure: YuWDOwPGprL6PiBZVeGaLOCHHgC18fQ6nq617tlt7XFCkG17r/xDWq3iiAyNxNUcwsD9CkWi5aXok8SlX3rQx84XC/sya2bi0+8Frt9EztcVxgMwWuX3Ll4mFHO7HnMhazoQYRPd0b0w4s7bFY2WidxCqjsMKRgAM26Gn+6oQto=
Expand Down
8 changes: 2 additions & 6 deletions tutorial-04_2-pattern-matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ struct Point { x: f64, y: f64 }

fn angle(vector: (f64, f64)) -> f64 {
let pi = f64::consts::PI;
/*
* A powerful application of pattern matching is destructuring:
* matching in order to bind names to the contents of data types.
*/
match vector {
(0.0, y) if y < 0.0 => 1.5 * pi,
(0.0, _) => 0.5 * pi,
(x, y) if x == 0.0 && y < 0.0 => 1.5 * pi,
(x, _) if x == 0.0 => 0.5 * pi,
(x, y) => (y / x).atan()
}
}
Expand Down
12 changes: 6 additions & 6 deletions tutorial-05_1-structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
*/
#[derive(Debug)]
struct Point {
x: f64,
y: f64
x: i32,
y: i32
}
fn main() {
let mut mypoint = Point { x: 1.0, y: 1.0 };
let origin = Point { x: 0.0, y: 0.0 };
let mut mypoint = Point { x: 1, y: 1 };
let origin = Point { x: 0, y: 0 };

println!("origin = {:?}", origin);

mypoint.y += 1.0; // mypoint is mutable, and its fields as well
mypoint.y += 1; // mypoint is mutable, and its fields as well
//origin.y += 1.0; // ERROR: assigning to immutable field

// `match` patterns destructure structs.
match mypoint {
Point { x: 0.0, y: yy } => println!("{}", yy),
Point { x: 0, y: yy } => println!("{}", yy),
Point { x: xx, y: yy } => println!("{} {}", xx, yy),
}

Expand Down

0 comments on commit a69a38d

Please sign in to comment.