You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update getrandom to 0.2
* Make sure that the error codes are identical to `getrandom`
* rand_core: Add links to Error cross-refs
Signed-off-by: Joe Richey <[email protected]>
Co-authored-by: Vinzent Steinberg <[email protected]>
Copy file name to clipboardExpand all lines: rand_core/src/error.rs
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,10 +28,14 @@ pub struct Error {
28
28
implError{
29
29
/// Codes at or above this point can be used by users to define their own
30
30
/// custom errors.
31
+
///
32
+
/// This is identical to [`getrandom::Error::CUSTOM_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.CUSTOM_START).
31
33
pubconstCUSTOM_START:u32 = (1 << 31) + (1 << 30);
32
34
/// Codes below this point represent OS Errors (i.e. positive i32 values).
33
35
/// Codes at or above this point, but below [`Error::CUSTOM_START`] are
34
36
/// reserved for use by the `rand` and `getrandom` crates.
37
+
///
38
+
/// This is identical to [`getrandom::Error::INTERNAL_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.INTERNAL_START).
35
39
pubconstINTERNAL_START:u32 = 1 << 31;
36
40
37
41
/// Construct from any type supporting `std::error::Error`
@@ -208,3 +212,14 @@ impl fmt::Display for ErrorCode {
208
212
209
213
#[cfg(feature = "std")]
210
214
impl std::error::ErrorforErrorCode{}
215
+
216
+
#[cfg(test)]
217
+
mod test {
218
+
#[cfg(feature = "getrandom")]
219
+
#[test]
220
+
fntest_error_codes(){
221
+
// Make sure the values are the same as in `getrandom`.
0 commit comments