Skip to content

Commit 9563e44

Browse files
authored
Merge pull request #6 from mozilla/doc-note
doc: Add an example
2 parents 607f703 + 473763d commit 9563e44

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,9 @@ jobs:
9494
# no memory and leak sanitizer support yet
9595
SANITIZERS="address thread"
9696
fi
97-
9897
for sanitizer in $SANITIZERS; do
9998
echo "Running tests with $sanitizer sanitizer..."
100-
RUSTFLAGS="-Z sanitizer=$sanitizer" cargo +nightly test -Z build-std --target "$TARGET"
99+
RUSTFLAGS="-Z sanitizer=$sanitizer" RUSTDOCFLAGS="-Z sanitizer=$sanitizer" cargo +nightly test -Z build-std --target "$TARGET"
101100
done
102101
103102
- name: Check formatting

.rustfmt.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Keep in sync with `Cargo.toml` `edition`.
2+
#
3+
# `rustfmt` envoked not through `cargo fmt` but directly does not pick up Rust
4+
# edition in `Cargo.toml`. Thus duplicate here.
5+
edition = "2021"
6+
7+
comment_width=100
8+
wrap_comments=true
9+
10+
imports_granularity="Crate"
11+
group_imports="StdExternalCrate"
12+
13+
format_code_in_doc_comments=true

src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ fn default_result<T>() -> Result<T, Error> {
2020
))
2121
}
2222

23-
/// Return the MTU of the interface that is used to reach the given remote socket address.
23+
/// Return the maximum transmission unit (MTU) of the local network interface towards the
24+
/// destination [`SocketAddr`] given in `remote`.
25+
///
26+
/// The returned MTU may exceed the maximum IP packet size of 65,535 bytes on some
27+
/// platforms for some remote destinations. (For example, loopback destinations on
28+
/// Windows.)
29+
///
30+
/// # Examples
31+
///
32+
/// ```
33+
/// let saddr = "127.0.0.1:443".parse().unwrap();
34+
/// let mtu = mtu::get_interface_mtu(&saddr).unwrap();
35+
/// println!("MTU towards {:?} is {}", saddr, mtu);
36+
/// ```
2437
///
2538
/// # Errors
2639
///

0 commit comments

Comments
 (0)