Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
225
3
주요 개념
서버 코드의 부담을 크게 덜 수 있다.
// ...
let tlv = Tlv {
type_code,
// 데이터의 관련 부분을 힙에 복사한다.
// TLV에서 길이에 대한 필드는 `u8` 하나(8비트) 크기다.
// 따라서 복사본의 최대 길이는 256바이트다.
value: input[2..2 + len].to_vec(),
};
데이터를 소유하는
Tlv
구조에는 수명 매개변수가 없으므로 서버 데이터 구조에도 수명 매개
변수가 없어도 된다. 그 결과, 두 버전의 루프 모두 정상 작동한다.
누가 크고 나쁜 복사를 두려워하랴
프로그래머가 복사 줄이기에 지나치게 집착하는 이유 중 하나는 러스트에서 복사와 할당을
명시적으로 하기 때문이다. 러스트에서
.
to
_
vec
()
이나
.
clone
()
과 같은 메서드나,
Box
::
new
()
와 같은 함수를 명시적으로 호출하면 복사와 할당이 발생한다는 것이 분명히 드러난다.
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