-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Proof of concept: Auto convert numbers to f64
- Loading branch information
Showing
3 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
use turtle::Turtle; | ||
|
||
struct MyCoord { | ||
x: u8, | ||
} | ||
|
||
impl From<MyCoord> for f64 { | ||
fn from(source: MyCoord) -> Self { | ||
f64::from(source.x) | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut turtle = Turtle::new(); | ||
|
||
for _ in 0..4 { | ||
turtle.forward(200.0); | ||
turtle.right(90.0); | ||
} | ||
turtle.forward(200); | ||
turtle.right(90); | ||
turtle.forward(200u8); | ||
turtle.right(90f32); | ||
turtle.forward(200.0); | ||
turtle.right(90.0); | ||
turtle.forward(MyCoord { x: 200 }); | ||
turtle.right(MyCoord { x: 90 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters