Penflip

Penflip - Write better with others

  • Loading...
  • Discover Projects
  • Help
  • Signup
  • Login
  • Welcome back!
    No account? Signup Close
    Ready to write better?
    Have an account? Login Close

sarojaba · Rust Doc Korean

Make Changes
46

5.4. 주석 (Comments) - 100%

이제 여러분들은 몇 개의 함수들을 가지게 되었고, 주석에 대해 배우는 것은 좋은 생각입니다. 주석은 다른 프로그래머에게 여러분의 코드에 관한 것들을 설명하는데 도움을 주도록 남기는 것입니다. 컴파일러는 주석 대부분을 무시합니다.

Rust는 두 종류의 주석(한 줄 주석과 문서 주석)을 가지고 있습니다.

// 라인 주석은 '//' 뒤에 오는 모든 것이고, 그 라인 끝까지 포함됩니다.
// Line comments are anything after ‘//’ and extend to the end of the line.

let x = 5; // this is also a line comment.
let x = 5; // 이 또한 라인 주석입니다.

// 무언가에 대해 긴 설명을 적어야 한다면, 라인 주석을
// 이렇게 적을 수 있습니다. // 와 주석 사이에 공백을 하나 넣어주세요. 그래야
// 더 보기 좋아집니다.
// If you have a long explanation for something, you can put line comments next
// to each other. Put a space between the // and your comment so that it’s
// more readable.

나머지 주석의 종류는 문서 주석입니다. 문서 주석은 // 대신에 ///를 사용하고, 내용으로 마크다운 표기를 지원합니다.

/// 주어진 숫자에 1 을 더함.
/// Adds one to the number given.
///
/// # Examples
///
/// ```
/// let five = 5;
///
/// assert_eq!(6, add_one(5));
/// # fn add_one(x: i32) -> i32 {
/// #     x + 1
/// # }
/// ```
fn add_one(x: i32) -> i32 {
    x + 1
}

이후에 나오는 요소 대신에 가지고 있는 요소을 설명하기 위해 또다른 스타일의 문서 주석 //! 이 있습니다. creates root (lib.rs) 또는 modules root (mod.rs) 내에서 흔히 사용됩니다:

//! # 러스트 표준 라이브러리
//!
//! 러스트 표준 라이브러리는 이식성있는 러스트 소프트웨어를 개발함에 있어
//! 필수적인 런타임 기능을 제공합니다.
//!
//! # The Rust Standard Library
//!
//! The Rust Standard Library provides the essential runtime
//! functionality for building portable Rust software.

문서 주석을 작성할 때, 사용 예제를 제공하면 아주, 아주 도움이 됩니다. 여기 새로운 매크로 assert_eq!를 사용한다는 것을 알려줍니다. 이 것은 두 값을 비교해서, 서로 다르면 panic!을 발생시킵니다. 이것은 문서화에 아주 도움이 됩니다. 값이 false라면 panic!을 발생시키는 assert! 매크로도 있습니다.

문서 주석에서 HTML 문서를 생성하고, 테스트로서 코드 예제를 실행하기 위해 rustdoc 도구를 사용할 수 있습니다.

Updated by Noizbuster over 3 years (view history)
5.3. 기본형 (Primitive Types) - 100% 5.5. 조건식 (if) - 100%

Contents

    Rust 문서 한글화 프로젝트 1. 소개(Introduction) 2. 시작하기(Getting Started) - 20% 3. Rust 배우기 (Learn Rust) - 100% 3.1. 추리 게임 (Guessing Game) - 100% 3.2. 식사하는 철학자들 (Dining Philosophers) - 100% 3.3. 다른 언어에 Rust 포함하기 (Rust Inside Other Languages) - 100% 4. 효과적인 Rust (Effective Rust) - 100% 4.1. 스택과 힙 (The Stack and the Heap) - 100% 4.2. 테스팅 (Testing) - 100% 4.3. 조건부 컴파일 (Conditional Compilation) - 70% 4.4. 문서화 (Documentation) - 20% 4.5. 반복자 (Iterators) - 100% 4.6. 동시성 (Concurrency) - 90% 4.7. 오류 처리 (Error Handling) - 4% 4.8. Choosing your Guarantees - 0% 4.9. 외부 함수 인터페이스 (Foreign Function Interface) - 50% 4.9. Borrow 와 AsRef 4.11. 배포 채널 (Release Channels) - 100% 5. 문법과 의미 (Syntax and Semantics) - 100% 5.1. 변수 바인딩 (Variable Bindings) - 100% 5.2. 함수 (Functions) - 100% 5.3. 기본형 (Primitive Types) - 100% 5.4. 주석 (Comments) - 100% 5.5. 조건식 (if) - 100% 5.6. 반복 (Loops) - 100% 5.7. 소유권 (Ownership) - 100% 5.8. 참조와 빌림 (References and Borrowing) - 100% 5.9. 수명 (Lifetimes) - 100% 5.10. 가변성 (Mutability) - 100% 5.11. 구조체 (Structs) - 100% 5.12. 열거형 (Enums) - 100% 5.13. 정합 (Match) - 100% 5.14. 패턴 (Patterns) - 80% 5.15. 메소드 문법 (Method Syntax) - 100% 5.16. 벡터 (Vectors) - 100% 5.17. 문자열(Strings) - 100% 5.18. 제너릭 (Generics) - 100% 5.19. 트레잇 (Traits) - 100% 5.20. 드랍 (Drop) - 100% 5.21. if let - 100% 5.22. 트레잇 객체 (Trait Objects) - 75% 5.23. 클로저 (Closures) - 10% 5.24. 전역 함수 사용법 (Universal Function Call Syntax) - 0% 5.25. 크레이트들과(Crate) 모듈들(Module) - 0% 9. 용어 색인 (Concordance) Show all
    Discussions 5 Pending changes 5 Contributors
    Download Share

    Download

    Working...

    Downloading...

    Downloaded!

    Download more

    Error!

    Your download couldn't be processed. Check for abnormalities and incorrect syntax. We've been notified of the issue.

    Back

    Download PDF Download ePub Download HTML Download Word doc Download text Download source (archive)

    Close
291 Words
1,619 Characters

Share

Collaborators make changes on their own versions, and all changes will be approved before merged into the main version.

Close

Penflip is made by Loren Burton
in Los Angeles, California

Tweet

    About

  • Team
  • Pricing
  • Our Story

    Quick Start

  • Markdown
  • Penflip Basics
  • Working Offline

    Support

  • Help
  • Feedback
  • Terms & Privacy

    Connect

  • Email
  • Twitter