μ—°μ‚°

fn interproduct(a: i32, b: i32, c: i32) -> i32 {
    return a * b + b * c + c * a;
}

fn main() {
    println!("κ²°κ³Ό: {}", interproduct(120, 100, 248));
}
This slide should take about 3 minutes.

main μ΄μ™Έμ˜ ν•¨μˆ˜λŠ” 이번이 μ²˜μŒμ΄μ§€λ§Œ μ˜λ―ΈλŠ” λͺ…ν™•ν•©λ‹ˆλ‹€. μ„Έ 개의 μ •μˆ˜λ₯Ό μ‚¬μš©ν•˜κ³  μ •μˆ˜λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€. ν•¨μˆ˜λŠ” λ‚˜μ€‘μ— 더 μžμ„Ένžˆ λ‹€λ£¨κ² μŠ΅λ‹ˆλ‹€.

μ‚°μˆ μ—°μ‚°μ€ λ‹€λ₯Έ 언어와 맀우 μœ μ‚¬ν•˜λ©° μš°μ„ μˆœμœ„κ°€ λΉ„μŠ·ν•©λ‹ˆλ‹€.

μ •μˆ˜ μ˜€λ²„ν”Œλ‘œλŠ” μ–΄λ–»κ²Œ λ˜λ‚˜μš”? C 및 C++μ—μ„œ λΆ€ν˜ΈμžˆλŠ” μ •μˆ˜μ˜ μ˜€λ²„ν”Œλ‘œλŠ” μ‹€μ œλ‘œ μ •μ˜λ˜μ§€ μ•ŠμœΌλ©°, λ‹€λ₯Έ ν”Œλž«νΌμ΄λ‚˜ μ»΄νŒŒμΌλŸ¬μ—μ„œ λ‹€λ₯Έ μž‘μ—…μ„ μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€. Rustμ—μ„œλŠ” μ •μˆ˜ μ˜€λ²„ν”Œλ‘œ μ‹œμ˜ λ™μž‘μ΄ μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

Change the i32’s to i16 to see an integer overflow, which panics (checked) in a debug build and wraps in a release build. There are other options, such as overflowing, saturating, and carrying. These are accessed with method syntax, e.g., (a * b).saturating_add(b * c).saturating_add(c * a).

사싀 μ»΄νŒŒμΌλŸ¬λŠ” μƒμˆ˜ ν‘œν˜„μ‹μ˜ μ˜€λ²„ν”Œλ‘œλ₯Ό κ°μ§€ν•˜λ―€λ‘œ 이 μ˜ˆμ—μ„œλŠ” λ³„λ„μ˜ ν•¨μˆ˜κ°€ ν•„μš”ν•©λ‹ˆλ‹€.