Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
84
이펙티브 러스트
트레이트 객체가 있다.
슬라이스
첫 번째 팻 포인터 타입인
슬라이스
slice
는 연속된 값 집합을 표현하며, 소유권이 없는 단순 포인
터에 길이 필드가 추가되어 크기가 단순 포인터의 두 배가 된다(
64
비트 플랫폼의 경우,
16
이트 ). 슬라이스 타입은
[
T
]
에 대한 레퍼런스인
&[
T
]
로 표기하는데,
T
타입 값이 연속적으로
모여 있음을 나타내는 개념 타입
notional
type
이다.
이런 개념 타입 (
[
T
]
)은 인스턴스화할 수 없는 대신, 이를 구현한 두 컨테이너가 제공된다. 첫
번째 컨테이너는 연달아 저장된 값의 묶음인 배열
array
로, 크기는 컴파일 타임에 정해진다. 즉,
다섯 개의 값으로 만든 배열은 항상 다섯 개의 값만 가진다. 따라서 슬라이스는 배열의 부분 집
합이라고 볼 수 있다(그림
1
-
4
).
let array: [u64; 5] = [0, 1, 2, 3, 4];
let slice = &array[1..3];
스택
slice
array
그림
1-4
스택 배열을 가리키는 스택 슬라이스
두 번째 컨테이너는
Vec
<
T
>
다. 벡터는 배열과 마찬가지로 값이 연달아 저장되지만,
Vec
에 담긴
85
1
타입
값의 개수가
push
(
value
)
등을 이용해 증가하거나,
pop
()
등을 이용해 감소할 수 있다는 점
이 다르다.
Vec
을 구성하는 내용은 크기가 ...
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