Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
165
3
주요 개념
조체를 만드는 것이 대체로 다루기 쉽다.
'static
수명은 스코프를 절대 벗어날 일이 없는 개체에 대한 레퍼런스로 사용된다. 그런 개체의 예로
는 글로벌 데이터, 의도적으로 누수된 힙의 항목 등이 있다.
수명 레이블은 수명이 ‘같음’을 나타내는 용도로만 사용된다. 따라서 출력 수명은 입력 수명 안에 포함
된다.
수명 레이블을 구체적으로 지정할 필요가 없다면 익명 수명 레이블 (
'_
)을 사용한다.
아이템
15
: 대여 검사기를 잘 파악하라
러스트에서 값마다 소유자가 있지만, 소유한 값을 코드의 다른 곳에 빌려줄 수 있다. 이런
borrowing
메커니즘은 레퍼런스의 생성과 사용 과정에 적용되며 관련 규칙에 어긋나지 않도록
대여 검사기
borrow
checker
가 지키고 있다.
러스트의 레퍼런스는 내부적으로
C
C
++ 코드에서 보던 것과 같은 포인터(아이템
8
)를 사
용하는데,
C
/
C
++에서 발생하던 문제를 방지하기 위해 러스트에는 몇 가지 규칙과 제약 조건
을 적용한다. 그 차이를 간단히 비교하면 다음과 같다.
러스트의 레퍼런스는
C
/
C
++와 마찬가지로 앰퍼샌드 (
&
)를 통해 생성한다(예:
&value
).
러스트의 레퍼런스는
C
++와 마찬가지로
nullptr
이 될 수 없다.
러스트의 레퍼런스는
C
/
C
++의 포인터처럼 ...
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