Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
317
6
표준 러스트를 넘어서
되는 코드의 사용성은 좋아진다. 여기서 일반 유저 스페이스란 메모리가 사실상 무한하거나,
메모리가 부족하다면 그보다 더 큰 문제가 발생한 것을 의미하는 환경을 말한다.
그러나 메모리가 부족한 환경에서 적절히 대처해야 하는 프로그램에는 ‘할당에 실패하지 않는
다’는 가정이 전혀 맞지 않다. 메모리 안전성이 떨어지는 구식 언어가 오히려 유리한 극히 드문
경우다.
C
언어는
malloc
으로 직접 할당하고 그 반환값이
NULL
인지 확인해야 할 정도로 저수준으로 작동한다.
C
++는 할당 실패가 발생하면
std::bad_alloc
예외를 던지는 예외 메커니즘을 활용한다.
6
그동안 리눅스
Linux
커널, 안드로이드,
Curl
도구와 같은 몇몇 유명 프로젝트에서 러스트 표준
라이브러리의 부족한 할당 실패 대처 능력에 대한 지적이 많았고, 현재 이를 보완하는 작업이
진행 중이다.
할당 실패에 대처하기 위한 첫 번째 단계는 ‘실패 가능한 컬렉션 할당’을 지원하는 것이다. 그래
서 할당이 관련된 컬렉션
API
에 실패 가능한 할당
fallible
allocation
을 추가했다. 대부분
Result
<_,
AllocError
>
를 반환하는
try
_<
operation
>
배리언트를 추가하는 방식으로 처리했다. 예를
들면 다음과 같다.
Vec::reserve ...
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