BoundedCastFromInt — 경계 처리 정수 변환 트레이트

BoundedCastFromInt — 경계 처리 정수 변환 트레이트

BoundedCastFromInt<T>는 정수를 래핑(wrapping)하거나 포화(saturating) 처리하며 변환하는 nightly 전용 트레이트예요.

출처: Rust 공식 문서

본문

pub trait BoundedCastFromInt<T>: Sized {
    fn wrapping_cast_from(value: T) -> Self;
    fn saturating_cast_from(value: T) -> Self;
    // ...
}

wrapping_cast_from은 오버플로를 순환(래핑)으로 처리하고, saturating_cast_from은 최솟값/최댓값에 멈추는 포화 방식으로 변환해요. nightly 전용 실험 API예요.

더 알아보기 (Learn more)

Rust 공식 문서