Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
280
이펙티브 러스트
그러면 함수 호출이 로그에 기록된다.
let x = 2;
let y = add_three(x);
println!("add_three({x}) = {y}");
log: calling function 'add_three'
log: called function 'add_three' => 5
add_three(2) = 5
이 매크로는 입력 토큰의 구조를 검사하고 출력 토큰을 새로 만들어야 하기 때문에 구현 코드
가 상당히 길다. 따라서 지면에 담지 않았지만,
syn
크레이트를 활용하면 이런 작업을 쉽게 처
리할 수 있다.
파생 매크로
마지막으로 소개할 절차적 매크로인 파생 매크로
derive
macro
는 생성된 코드를 데이터 구조 정
의(
struct
,
enum
,
union
)와 자동으로 연결해 준다. 이 점은 속성형 매크로와 비슷하지만,
derive
매크로만이 가진 몇 가지 주의할 특성이 있다.
첫째,
derive
매크로는 입력 토큰을 교체하는 것이 아니라 입력 토큰에 추가한다. 즉, 데이터
구조 정의는 그대로 두고 일부 코드를 매크로가 추가하는 것이다.
둘째,
derive
매크로로 헬퍼 속성을 선언할 수 있으며 이 속성은 특수 처리가 필요한 데
이터 구조의 일부분을 표시하는 데 사용할 수 있다. 예를 들어 파생 매크로인
serde
Deserialize
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