From e6cd817d086c070184117b226fa6c8827ecbc046 Mon Sep 17 00:00:00 2001 From: nomicon-kr Date: Mon, 9 Sep 2024 17:45:24 +0900 Subject: [PATCH] Update coercions.md --- src/coercions.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/coercions.md b/src/coercions.md index ffff83f..deb7b98 100644 --- a/src/coercions.md +++ b/src/coercions.md @@ -1,14 +1,11 @@ -# Coercions +# 강제 변환 -Types can implicitly be coerced to change in certain contexts. -These changes are generally just *weakening* of types, largely focused around pointers and lifetimes. -They mostly exist to make Rust "just work" in more cases, and are largely harmless. +타입들은 특정한 상황들에서는 묵시적으로 강제 변환될 수 있습니다. 이런 변화들은 일반적으로 타입 시스템을 *약화시키는* 것인데, 주로 포인터와 수명에 초점이 맞춰져 있습니다. 이런 것들은 주로 많은 상황에서 러스트가 "그냥 잘 작동"하도록 하기 위하여 존재하며, 꽤나 위험성이 없습니다. -For an exhaustive list of all the types of coercions, see the [Coercion types] section on the reference. +모든 강제 변환의 종류에 대해서는 참조서의 [강제 변환 타입][coercion-types] 섹션을 보세요. -Note that we do not perform coercions when matching traits (except for receivers, see the [next page][dot-operator]). -If there is an `impl` for some type `U` and `T` coerces to `U`, that does not constitute an implementation for `T`. -For example, the following will not type check, even though it is OK to coerce `t` to `&T` and there is an `impl` for `&T`: +트레잇을 매칭할 때는 강제 변환을 실행하지 않는다는 것을 유의하세요 (except for receivers, [다음 페이지][dot-operator]를 보세요). 만약 어떤 타입 `U`를 위한 `impl`이 있고 `T`가 `U`로 강제 변환된다면, `T`를 위한 구현으로 인정되지는 않습니다. +예를 들어 다음의 코드는 타입 검사를 통과하지 못할 텐데, `t`를 `&T`로 강제 변환해도 괜찮고 `&T`를 위한 `impl`이 있는데도 그렇습니다: ```rust,compile_fail trait Trait {} @@ -23,7 +20,7 @@ fn main() { } ``` -which fails like as follows: +이는 다음의 에러를 내뱉습니다: ```text error[E0277]: the trait bound `&mut i32: Trait` is not satisfied @@ -40,5 +37,5 @@ error[E0277]: the trait bound `&mut i32: Trait` is not satisfied = note: `Trait` is implemented for `&i32`, but not for `&mut i32` ``` -[Coercion types]: ../reference/type-coercions.html#coercion-types +[coercion-types]: https://doc.rust-lang.org/reference/type-coercions.html#coercion-types [dot-operator]: ./dot-operator.html