The datatypes are built-in the language or built-in std?

i don't understand are the datatypes like :

i8 - i16 - i32 - i64 - i128 - isize 
u8 - u16 - u32 - u64 - u128 - usize 
f32 
f64
&str
bool
char

built-in the language or built-in std ?

if built-in the language why would they be exist in std ???

These are primitive types, which are part of the language.

str is a dynamically sized type (with [u8] layout, but guaranteed to contain valid UTF-8 encoded text), and &str is the borrowed form for it.

1 Like

What do you mean by "exist in std"?

Maybe they mean the core::str, core::f32, etc. modules?

but they exist in std too why ?

If you mean why are they defined in std, they're not. There is no struct str { ... } in std.

If you mean why can they be named in std, as part of the language, they exist in all Rust code.

If you mean why to the modules and implementations on the types exist in std, it's because that code has to exist somewhere so that it can be compiled into a library your Rust programs can use, so that it's documentation can be generated, etc.

If you mean something else, maybe include a link to it so we have a better idea on how to answer.

6 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.