Update Examples
parent
98df7d16e1
commit
4c11a5126c
10
Examples.md
10
Examples.md
@ -73,10 +73,10 @@ fn main
|
|||||||
let logical: bool = true
|
let logical: bool = true
|
||||||
|
|
||||||
let a_float: f64 = 1.0 // Regular annotation
|
let a_float: f64 = 1.0 // Regular annotation
|
||||||
let an_integer = 5i32 // Suffix annotation
|
an_integer = 5i32 // Suffix annotation
|
||||||
|
|
||||||
let default_float = 3.0 // `f64`
|
let default_float = 3.0 // `f64`
|
||||||
let default_integer = 7 // `i32`
|
default_integer = 7 // `i32`
|
||||||
|
|
||||||
// Can infer from another line; here i64:
|
// Can infer from another line; here i64:
|
||||||
let mut inferred_type = 12
|
let mut inferred_type = 12
|
||||||
@ -289,13 +289,13 @@ struct Rectangle
|
|||||||
fn main()
|
fn main()
|
||||||
// Create struct with field init shorthand
|
// Create struct with field init shorthand
|
||||||
let name = s"Peter" // note s-string
|
let name = s"Peter" // note s-string
|
||||||
let age = 27
|
age = 27
|
||||||
let peter = Person name, age
|
peter = Person name, age
|
||||||
|
|
||||||
println! "{:?}", peter
|
println! "{:?}", peter
|
||||||
|
|
||||||
let point: Point = Point x: 10.3, y: 0.4
|
let point: Point = Point x: 10.3, y: 0.4
|
||||||
let another_point: Point = Point x: 5.2, y: 0.2
|
another_point: Point = Point x: 5.2, y: 0.2
|
||||||
|
|
||||||
println! "point coordinates: ({}, {})", point.x, point.y
|
println! "point coordinates: ({}, {})", point.x, point.y
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user