Rustdoc

Rust์˜ ์•„์ดํ…œ(item)์€ /// ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์„œํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

/// Determine whether the first argument is divisible by the second argument.
///
/// If the second argument is zero, the result is false.
fn is_divisible_by(lhs: u32, rhs: u32) -> bool {
    if rhs == 0 {
        return false;  // Corner case, early return
    }
    lhs % rhs == 0     // The last expression in a block is the return value
}

์ฝ˜ํ…์ธ ๋Š” ๋งˆํฌ๋‹ค์šด์œผ๋กœ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค. ๊ฒŒ์‹œ๋œ ๋ชจ๋“  Rust ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํฌ๋ ˆ์ดํŠธ๋Š” rustdoc ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ docs.rs์— ์ž๋™์œผ๋กœ ๋ฌธ์„œํ™”๋ฉ๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ API์˜ ๋ชจ๋“  ๊ณต๊ฐœ ํ•ญ๋ชฉ์€ ์ด ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์„œํ™”๋ฉ๋‹ˆ๋‹ค.

  • docs.rs/rand์—์„œ rand ํฌ๋ ˆ์ดํŠธ์šฉ์œผ๋กœ ์ƒ์„ฑ๋œ ๋ฌธ์„œ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

  • ์ด ์Šฌ๋ผ์ด๋“œ์˜ ์˜ˆ์ œ ์ฝ”๋“œ๋Š” ๋ฌธ์„œํ™” ์ฃผ์„์ด ์ƒ๋žต๋˜์–ด ์žˆ์ง€๋งŒ, ์‹ค์ œ ์ฝ”๋“œ๋ผ๋ฉด ๋ฌธ์„œํ™” ์ฃผ์„์„ ๋ฐ˜๋“œ์‹œ ์จ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • ๋ฌธ์„œ ๋‚ด๋ถ€ ์ฃผ์„ ๋ชจ๋“ˆ ํŽ˜์ด์ง€ ๋’ท๋ถ€๋ถ„์—์„œ ๋‹ค๋ฃจ๋ฉฐ ์—ฌ๊ธฐ์„œ ๋‹ค๋ฃจ์ง€ ์•Š์•„๋„ ๋ฉ๋‹ˆ๋‹ค.

  • ๋ฌธ์„œํ™” ์ฃผ์„์€ ์ฝ”๋“œ๋ฅผ ํฌํ•จํ•  ์ˆ˜๋„ ์žˆ์œผ๋ฉฐ, ์ด ์ฝ”๋“œ๋Š” cargo test๋ฅผ ํ†ตํ•ด ํ…Œ์ŠคํŠธ๋กœ ๋™์ž‘ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ์—์„œ ๋” ์ž์„ธํžˆ ๋‹ค๋ฃจ๊ฒ ์Šต๋‹ˆ๋‹ค.