Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
109
2
트레이트
CHAPTER
트레이트
2
러스트 타입 시스템의 또 다른 핵심은 트레이트
trait
를 이용해 서로 다른 타입 사이의 공통 동작
을 인코딩하는 것이다. 러스트의 트레이트는 다른 언어의 인터페이스
interface
와 거의 같지만
제네
generic
(아이템
12
)과 연계되어 런타임 오버헤드 없이 재사용할 수 있다.
이 장에서는 컴파일러를 비롯한 러스트 툴체인에서 제공하는 여러 가지 표준 트레이트를 살펴
보고, 원하는 동작을 트레이트로 인코딩해서 사용하는 방법에 대해 조언한다.
아이템
10
: 표준 트레이트를 잘 익혀둬라
러스트는 타입 시스템의 동작을 세밀하게 표현하도록 제공하는 표준 트레이트를 통해 타입 시
스템의 핵심 동작을 타입 시스템 자체에 인코딩한다 (아이템
2
).
C
++에 익숙한 프로그래머라면 복사 생성자
copy
-
constructor
, 소멸자
destructor
, 동등 연산자
equality
operator
와 대입 연산자
assignment
operator
등과 상당히 비슷하다고 느낄 것이다.
C
++와 마찬가지로 사용자 정의 타입을 구현할 때 이런 표준 트레이트를 활용하면 좋다. 그러
면 사용자 정의 타입에 있어야 할 연산이 없을 때 그 연산이 속한 트레이트를 러스트 컴파일러
가 알아내 오류 메시지를 구체적으로 출력할 수 있다.
110
이펙티브 러스트 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리

Publisher Resources

ISBN: 9791169212946