#[non_exhaustive]pub enum RngError {
Shape(ShapeError),
InvalidRange {
low: i32,
high: i32,
},
InvalidProbability {
index: usize,
},
InvalidArgument {
reason: &'static str,
},
}Expand description
randint 専用のエラー型。shape 起因の不整合(要素数オーバー
フロー等)は Tensor::zeros 等と同じ ShapeError へ委譲し
(From<ShapeError> 実装)、low >= high という範囲自体の不正は
ShapeError の対象外(shape 不整合限定。crates/tensor-core/src/error.rs
の ShapeError variant 一覧参照)であるため本型で新設する
(イシュー #1725)。bernoulli/multinomial/normal・
Generator(イシュー #2156)も同じ型を再利用し、確率・重み・
mean/std の検証違反用に variant を追加する(下記)。
#[non_exhaustive]: ShapeError と同じ理由(公開 API 非破壊。
.claude/rules/security.md)で後続の検査項目追加に備える。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Shape(ShapeError)
shape 起因の不整合(要素数積のオーバーフロー等)。
InvalidRange
randint(low, high, ..) の low >= high(空区間・逆転区間)。
InvalidProbability
bernoulli/multinomial が受け取る確率・重みの論理 index
index が非有限、または bernoulli では [0, 1] の範囲外
(イシュー #2156)。乱数は一切消費しない(全要素の事前検証を
ロック取得前に終えてから抽選に入る契約)。
InvalidArgument
multinomial/normal の引数不正(reason は固定文言。
n == 0・n > i32::MAX・行和が 0 以下・非復元抽出で
num_samples が正の重みの個数を超える・mean/std が非有限・
std < 0 等。イシュー #2156)。乱数は一切消費しない。
Trait Implementations§
impl Eq for RngError
Source§impl Error for RngError
impl Error for RngError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ShapeError> for RngError
impl From<ShapeError> for RngError
Source§fn from(err: ShapeError) -> RngError
fn from(err: ShapeError) -> RngError
impl StructuralPartialEq for RngError
Auto Trait Implementations§
impl Freeze for RngError
impl RefUnwindSafe for RngError
impl Send for RngError
impl Sync for RngError
impl Unpin for RngError
impl UnsafeUnpin for RngError
impl UnwindSafe for RngError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more