Comments

Mickey·2022년 1월 20일

Rust By Example

목록 보기
3/4
post-thumbnail

https://doc.rust-lang.org/rust-by-example/hello/comment.html

모든 프로그램에는 주석이 필요하며 Rust는 몇 가지 다른 종류를 지원

  • 컴파일러가 무시하는 일반적인 주석
    • // 줄의 끝까지 가는 줄 주석
    • /* 블럭 주석 */
  • HTML 라이브러리 문서로 구문 분석되는 문서 주석
    • /// 다음 항목에 대한 라이브러리 문서를 생성
    • //! 블럭에 대한 라이브러리 문서를 생성 !//
fn main() {
    // This is an example of a line comment
    // There are two slashes at the beginning of the line
    // And nothing written inside these will be read by the compiler

    // println!("Hello, world!");

    // Run it. See? Now try deleting the two slashes, and run it again.

    /* 
     * This is another type of comment, a block comment. In general,
     * line comments are the recommended comment style. But
     * block comments are extremely useful for temporarily disabling
     * chunks of code. /* Block comments can be /* nested, */ */
     * so it takes only a few keystrokes to comment out everything
     * in this main() function. /*/*/* Try it yourself! */*/*/
     */

    /*
    Note: The previous column of `*` was entirely for style. There's
    no actual need for it.
    */

    // You can manipulate expressions more easily with block comments
    // than with line comments. Try deleting the comment delimiters
    // to change the result:
    let x = 5 + /* 90 + */ 5;
    println!("Is `x` 10 or 100? x = {}", x);
}

profile
Mickey

0개의 댓글