Skip to content

Commit 908328f

Browse files
committed
Document when types have OS-dependent sizes
As per issue #43601, types that can change size depending on the target operating system should say so in their documentation. I used this template when adding doc comments: The size of a(n) <name> struct may vary depending on the target operating system, and may change between Rust releases. For enums, I used "instance" instead of "struct".
1 parent 1733a61 commit 908328f

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/libstd/io/stdio.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,27 @@ thread_local! {
3030
///
3131
/// This handle is not synchronized or buffered in any fashion. Constructed via
3232
/// the `std::io::stdio::stdin_raw` function.
33+
///
34+
/// The size of a StdinRaw struct may vary depending on the target operating
35+
/// system, and may change between Rust releases.
3336
struct StdinRaw(stdio::Stdin);
3437

3538
/// A handle to a raw instance of the standard output stream of this process.
3639
///
3740
/// This handle is not synchronized or buffered in any fashion. Constructed via
3841
/// the `std::io::stdio::stdout_raw` function.
42+
///
43+
/// The size of a StdoutRaw struct may vary depending on the target operating
44+
/// system, and may change between Rust releases.
3945
struct StdoutRaw(stdio::Stdout);
4046

4147
/// A handle to a raw instance of the standard output stream of this process.
4248
///
4349
/// This handle is not synchronized or buffered in any fashion. Constructed via
4450
/// the `std::io::stdio::stderr_raw` function.
51+
///
52+
/// The size of a StderrRaw struct may vary depending on the target operating
53+
/// system, and may change between Rust releases.
4554
struct StderrRaw(stdio::Stderr);
4655

4756
/// Constructs a new raw handle to the standard input of this process.

src/libstd/net/addr.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ use slice;
2828
/// as possibly some version-dependent additional information. See [`SocketAddrV4`]'s and
2929
/// [`SocketAddrV6`]'s respective documentation for more details.
3030
///
31+
/// The size of a SocketAddr instance may vary depending on the target operating
32+
/// system, and may change between Rust releases.
33+
///
3134
/// [IP address]: ../../std/net/enum.IpAddr.html
3235
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
3336
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
@@ -61,6 +64,9 @@ pub enum SocketAddr {
6164
///
6265
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses.
6366
///
67+
/// The size of a SocketAddrV4 struct may vary depending on the target operating
68+
/// system, and may change between Rust releases.
69+
///
6470
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
6571
/// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html
6672
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
@@ -88,6 +94,9 @@ pub struct SocketAddrV4 { inner: c::sockaddr_in }
8894
///
8995
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses.
9096
///
97+
/// The size of a SocketAddrV6 struct may vary depending on the target operating
98+
/// system, and may change between Rust releases.
99+
///
91100
/// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3
92101
/// [IPv6 address]: ../../std/net/struct.Ipv6Addr.html
93102
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html

src/libstd/net/ip.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ use sys_common::{AsInner, FromInner};
2626
/// This enum can contain either an [`Ipv4Addr`] or an [`Ipv6Addr`], see their
2727
/// respective documentation for more details.
2828
///
29+
/// The size of an IpAddr instance may vary depending on the target operating
30+
/// system, and may change between Rust releases.
31+
///
2932
/// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
3033
/// [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
3134
///
@@ -61,6 +64,9 @@ pub enum IpAddr {
6164
///
6265
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses.
6366
///
67+
/// The size of an Ipv4Addr struct may vary depending on the target operating
68+
/// system, and may change between Rust releases.
69+
///
6470
/// [IETF RFC 791]: https://tools.ietf.org/html/rfc791
6571
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
6672
///
@@ -93,6 +99,9 @@ pub struct Ipv4Addr {
9399
///
94100
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses.
95101
///
102+
/// The size of an Ipv6Addr struct may vary depending on the target operating
103+
/// system, and may change between Rust releases.
104+
///
96105
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
97106
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
98107
///

src/libstd/time.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ pub use core::time::Duration;
4949
/// allows measuring the duration between two instants (or comparing two
5050
/// instants).
5151
///
52+
/// The size of an Instant struct may vary depending on the target operating
53+
/// system, and may change between Rust releases.
54+
///
5255
/// Example:
5356
///
5457
/// ```no_run
@@ -88,6 +91,9 @@ pub struct Instant(time::Instant);
8891
/// fixed point in time, a `SystemTime` can be converted to a human-readable time,
8992
/// or perhaps some other string representation.
9093
///
94+
/// The size of a SystemTime struct may vary depending on the target operating
95+
/// system, and may change between Rust releases.
96+
///
9197
/// [`Instant`]: ../../std/time/struct.Instant.html
9298
/// [`Result`]: ../../std/result/enum.Result.html
9399
/// [`Duration`]: ../../std/time/struct.Duration.html

0 commit comments

Comments
 (0)