Inflearn brand logo image

인프런 커뮤니티 질문&답변

Lemon Blue님의 프로필 이미지
Lemon Blue

작성한 질문수

우아한 고성능 프로그래밍 언어 Rust 입문 및 활용

구조체 기초

튜플 구조체에서 println! 사용시 에러가 발생합니다.

해결된 질문

작성

·

105

0

struct Color(i32, i32, i32);
struct Point(i32, i32, i32);

fn main() {
    let c = Color(255, 0, 0); // RGB 값 (빨간색)
    let p = Point(0, 0, 0); // 3D 공간의 원점

    println!("Color is {:?}", c);
    println!("Point is {:?}", p);
}

Color doesn't implement Debug
the trait Debug is not implemented for Color
add #[derive(Debug)] to Color or manually impl Debug for Color

위와 같은 에러가 발생하는데요 #[dervie(Debug)]

구문을 struct 상단에 기입했을 때 해결이 됩니다.

하지만 어떤 원리로 해결이 된건지는 모르겠습니다.

 

가르침 부탁드립니다.

답변 1

1

Lemon Blue님의 프로필 이미지
Lemon Blue
질문자

바로 다음 강의에 설명이 있었네요. 이해했습니다.

Lemon Blue님의 프로필 이미지
Lemon Blue

작성한 질문수

질문하기