Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
64
이펙티브 러스트
배열을 슬라이스로 변환한다.
(구체적인 항목이 구현하는 트레이트에 대해 ) 구체적인 항목을 트레이트 객체로 변환한다.
수명이 ‘더 짧은’ 항목으로 변환한다(아이템
14
).
26
사용자 정의 타입에 의해 동작이 영향을 받을 수 있는 강제 변환은 두 가지뿐이다. 하나는 사용
자 정의 타입이
Deref
DerefMut
트레이트를 구현하는 경우이고, 다른 하나는 구체적인 항
목이 트레이트 객체로 변환되는 경우다.
첫 번째 강제 변환의 경우 사용자 정의 타입이 일종의 스마트 포인터 역할을 한다(아이템
8
).
이때 컴파일러는 스마트 포인터 항목에 대한 레퍼런스를 (
Target
이 가리키는 ) 스마트 포인터
가 포함하는 타입의 항목에 대한 레퍼런스로 강제 변환한다.
두 번째 강제 변환은 구체적인 항목을 트레이트 객체로 변환할 때 해당 항목에 대한
팻 포인터
fat
pointer
를 생성한다. 그 이유는 해당 항목의 메모리 위치에 대한 포인터뿐만 아니라, 해당 트레이트
의 구체적인 타입에 대한 구현을 위한
vtable
에 대한 포인터도 포함하기 때문이다(아이템
8
).
아이템
6
: 뉴타입 패턴을 적극 활용하라
아이템
1
에서 설명했듯이 튜플 구조체의 필드에 이름을 붙일 수는 없고 번호로 참조해야 한
다(예:
self
.
0
). 이번 아이템에서는 튜플 구조체
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