Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
212
이펙티브 러스트
입력으로 구성된
String
이 사용되는 시점까지 패닉이 지연된다.
이번 아이템
18
에서 제시하는 조언을 잘 따른다고 가정할 때, 몇 가지 유의할 사항이 있다. 첫
번째는 패닉이 다양한 형태로 숨어 있다는 것이다.
panic
!
을 피한다는 것은 다음도 피한다는
뜻이다.
unwrap()
unwrap_err()
expect()
expect_err()
unreachable!()
다음과 같은 문제는 더 찾기 힘들다.
slice[index]
에서 인덱스가 범위를 벗어난 경우
x / y
에서
y
0
인 경우
패닉 피하기와 관련된 또 다른 사실은 사람이 지속적으로 경계하는 방안은 결코 좋은 방법이
아니라는 것이다.
그러나 기계가 지속적으로 경계하는 것은 괜찮다. 새 코드가 추가될 때 패닉이 발생할 수 있는
부분을 검사하는 기능을
CI
시스템 (아이템
32
)에 추가하면 훨씬 안정적으로 패닉을 피할 수
있다. 간단한 방법은 앞서 본 것처럼 가장 흔히 볼 수 있는 패닉 진입점에 대해서는 간단히 그
grep
으로 검사하는 것이다. 좀 더 철저하게 검사하려면 러스트 생태계에서 제공하는 보조 도
구(아이템
31
)를 활용한다. 예를 들어
no
_
panic
크레이트를 사용하도록 빌드를 설정한다.
아이템
19
: 리플렉션 사용을 자제하라
다른 언어에서 갓 넘어온 러스트 프로그래머는 리플렉션
reflection
을 자주 활용하곤 한다. 러스트
에 와서도 리플렉션 기반으로 설계해서 구현하려고 많은 시간을 허비하다가, 나중에서야 그런
식으로는 제대로 ...
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