Update subtyping.md

pull/464/head
nomicon-kr 9 months ago committed by GitHub
parent 462ab74f55
commit d2b41f3fa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,10 +4,10 @@
수명을 유연하게 사용하면서도 수명의 오용을 방지하기 위해서, 러스트는 **Subtyping****변성(變性, Variance)** 을 사용합니다.
Let's start with an example.
예제와 함께 시작해 보죠.
```rust
// Note: debug expects two parameters with the *same* lifetime
// 주의: debug는 수명이 *같은* 두 개의 매개변수를 기대합니다.
fn debug<'a>(a: &'a str, b: &'a str) {
println!("a = {a:?} b = {b:?}");
}
@ -16,7 +16,7 @@ fn main() {
let hello: &'static str = "hello";
{
let world = String::from("world");
let world = &world; // 'world has a shorter lifetime than 'static
let world = &world; // 'world 는 'static 보다 짧은 수명입니다
debug(hello, world);
}
}

Loading…
Cancel
Save