문제
상수 변수에 데이터 타입이 명시되지 않아 발생한 에러이다.
풀이
소스 코드를 살펴보자
// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;
fn main() {
println!("Number: {NUMBER}");
}
`TODO`에서도 상수 변수 선언 부분을 수정하라고 지시하고 있다.
데이터 타입을 명시해 주자.
// TODO: Change the line below to fix the compiler error.
const NUMBER:i32 = 3;
fn main() {
println!("Number: {NUMBER}");
}
저장하면,
해결
Rust에서 상수를 선언할 때에는 데이터 타입을 명시해 주자!
'Programming Language > RUST' 카테고리의 다른 글
Rust 함수 동작 원리 (0) | 2024.10.22 |
---|---|
[Rustling] exercises/01_variables/variables5.rs 풀기 (0) | 2024.10.11 |
[Restling] exercises/01_variables/variables4.rs 풀기 (0) | 2024.10.11 |
[Rustling] exercises/01_variables/variables3.rs 풀기 (0) | 2024.10.11 |
[Rustling] exercises/01_variables/variables2.rs 풀기 (0) | 2024.10.11 |