Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
89
1
타입
화한 것이다.
Clone
은 러스트 레퍼런스(
&
T
)를 요구하는 반면
ToOwned
Borrow
를 구현하는
것들을 다룬다.
이렇게 하면 레퍼런스와 이동 항목
moved
item
을 통합된 방식으로 다양하게 처리할 수 있다.
특정 타입에 대한 레퍼런스를 처리하는 함수가
Borrow
를 받을 수 있어서, 레퍼런스뿐만 아니라 이동 항
목에 대해서도 호출할 수 있다.
특정 타입으로 된 소유 항목에 대해 작동하는 함수는
ToOwned
를 받을 수 있어서, 이동 항목뿐만 아니라
항목에 대한 레퍼런스로도 호출할 수 있다. 이 함수에 전달된 모든 레퍼런스는 로컬에서 소유 항목으로
복제된다.
포인터 타입은 아니지만, 이와 같은 상황을 처리하는 또 다른 방법을 제공하는
Cow
타입도 가
볍게 살펴보자.
Cow
는 대여 데이터에 대한 레퍼런스나 소유 데이터를 가질 수 있는
enum
이다.
Cow
란 이름이 좀 특이한데, ‘
clone
-
on
-
write
’의 줄임말로 수정이 필요한 시점까지 입력은 대
여 데이터로 유지되지만, 데이터를 변경해야 하는 시점에는 소유 데이터의 복제본이 된다.
스마트 포인터 타입
러스트 표준 라이브러리는 표준 라이브러리 트레이트를 통해서 포인터처럼 작동하는 타입
을 다양하게 제공한다. 이러한 스마트 포인터
smart
pointer
타입은 각각 특정한 의미와 보장을 제
공하는데, 잘 조합해서 사용하면 포인터 동작을 세밀하게 제어할 수 있다는 장점이 있지만,
Rc
<
RefCell
<
Vec
<
T
>>>
와 같이 결과 타입이 굉장히 복잡해질 수 있다는 ...
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