Skip to content

Commit 702c54a

Browse files
authored
Add documentation for how to do the equivalent of gethostname. (#880)
Add documentation showing how to get the `gethostname` value using `uname`.
1 parent 3a53dfe commit 702c54a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/system.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub use backend::system::types::Sysinfo;
2020
/// `uname()`—Returns high-level information about the runtime OS and
2121
/// hardware.
2222
///
23+
/// For `gethostname()`, use [`Uname::nodename`] on the result.
24+
///
2325
/// # References
2426
/// - [POSIX]
2527
/// - [Linux]
@@ -40,6 +42,7 @@ pub use backend::system::types::Sysinfo;
4042
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=uname&section=3
4143
/// [illumos]: https://illumos.org/man/2/uname
4244
/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Platform-Type.html
45+
#[doc(alias = "gethostname")]
4346
#[inline]
4447
pub fn uname() -> Uname {
4548
Uname(backend::system::syscalls::uname())
@@ -61,6 +64,8 @@ impl Uname {
6164
/// This is intended to be a network name, however it's unable to convey
6265
/// information about hosts that have multiple names, or any information
6366
/// about where the names are visible.
67+
///
68+
/// This corresponds to the `gethostname` value.
6469
#[inline]
6570
pub fn nodename(&self) -> &CStr {
6671
Self::to_cstr(self.0.nodename.as_ptr().cast())

0 commit comments

Comments
 (0)