• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/25-Apr-2025-436294

.cargo-checksum.jsonD25-Apr-2025984 11

Android.bpD25-Apr-20251.3 KiB5752

CHANGELOG.mdD25-Apr-20253.4 KiB10367

Cargo.tomlD25-Apr-20251.3 KiB5043

LICENSED25-Apr-202510.6 KiB202169

LICENSE-APACHED25-Apr-202510.6 KiB202169

LICENSE-MITD25-Apr-20251 KiB2622

METADATAD25-Apr-2025377 1817

MODULE_LICENSE_APACHE2D25-Apr-20250

README.mdD25-Apr-20251.4 KiB6337

TEST_MAPPINGD25-Apr-202573 87

cargo_embargo.jsonD25-Apr-202569 65

clippy.tomlD25-Apr-202514 21

README.md

1# errno [![CI](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml/badge.svg)](https://github.com/lambda-fairy/rust-errno/actions/workflows/main.yml) [![Cargo](https://img.shields.io/crates/v/errno.svg)](https://crates.io/crates/errno)
2
3Cross-platform interface to the [`errno`][errno] variable. Works on Rust 1.56 or newer.
4
5Documentation is available at <https://docs.rs/errno>.
6
7[errno]: https://en.wikipedia.org/wiki/Errno.h
8
9
10## Dependency
11
12Add to your `Cargo.toml`:
13
14```toml
15[dependencies]
16errno = "*"
17```
18
19
20## Comparison with `std::io::Error`
21
22The standard library provides [`Error::last_os_error`][last_os_error] which fetches `errno` in the same way.
23
24This crate provides these extra features:
25
26- No heap allocations
27- Optional `#![no_std]` support
28- A `set_errno` function
29
30[last_os_error]: https://doc.rust-lang.org/std/io/struct.Error.html#method.last_os_error
31
32
33## Examples
34
35```rust
36extern crate errno;
37use errno::{Errno, errno, set_errno};
38
39// Get the current value of errno
40let e = errno();
41
42// Set the current value of errno
43set_errno(e);
44
45// Extract the error code as an i32
46let code = e.0;
47
48// Display a human-friendly error message
49println!("Error {}: {}", code, e);
50```
51
52
53## `#![no_std]`
54
55Enable `#![no_std]` support by disabling the default `std` feature:
56
57```toml
58[dependencies]
59errno = { version = "*", default-features = false }
60```
61
62The `Error` impl will be unavailable.
63