Variable Types - variables2.rs
With this file, we're starting to look at data types.
It's not happy with line 7, where we tell it that we are going to be using a variable,
x. It says,
consider giving , but let's be honest, when it says consider, it really means you have to.
x a type
But the thing is, you may recall that with
variables1.rs, we never had to.
The thing is that previously, when we said that we were going to use a variable, we simultaneously assigned it. And when we assign it, Rust can make some inferences about what our intent is. In this example here, it's an integer.
So we are going to want. to do something like this:
With this syntax, we are saying, hey we want to use a variable x, it's going to be a signed 8-bit integer, and we are going to store
10 in it. There are a number of various integer types, and you can read all about them, in the Rust Programming Language's docs on Data Types.