Create a new instance of types Char and I32


#1

Hey there.
I want to create a new instance of the types Char and I32.

To make a new instance of String, we do like this : let mut new_instance:String = String::new();.
But what about a new instance of Char or I32 (or any other types ?)…

I guessed it’s something like this : let mut new_instance:char = Char::new(); but it doesn’t works and i get an > error : error[E0433]: failed to resolve. Use of undeclared type or moduleChar`

–> src\main.rs:8:33
|
8 | let mut new_instance:char = Char::new();
| ^^^^ Use of undeclared type or module `Char``

Thanks for any help.


#2

'x' and 42 or 42i32.


#3

These are built-in primitive types. They’re not objects, they’re just a few bytes, so there’s no ceremony in creating them. They’re also Copy types, so they can be cheaply created, copied and forgotten at will.