Skip to content

Commit e8879e3

Browse files
authored
docs: fix doc style & make clippy happy (#2478)
* docs: fix doc style & make clippy happy * style: format code * docs: fix test doc style * style: format code
1 parent ae338df commit e8879e3

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

src/mqueue.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,11 @@ pub fn mq_getattr(mqd: &MqdT) -> Result<MqAttr> {
260260
})
261261
}
262262

263-
/// Set the attributes of the message queue. Only `O_NONBLOCK` can be set, everything else will be ignored
264-
/// Returns the old attributes
265-
/// It is recommend to use the `mq_set_nonblock()` and `mq_remove_nonblock()` convenience functions as they are easier to use
263+
/// Set the attributes of the message queue. Only `O_NONBLOCK` can be set,
264+
/// everything else will be ignored. Returns the old attributes.
265+
///
266+
/// It is recommend to use the `mq_set_nonblock()` and `mq_remove_nonblock()`
267+
/// convenience functions as they are easier to use.
266268
///
267269
/// [Further reading](https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_setattr.html)
268270
pub fn mq_setattr(mqd: &MqdT, newattr: &MqAttr) -> Result<MqAttr> {

src/sys/socket/sockopt.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,25 @@ sockopt_impl!(
303303
#[cfg(feature = "net")]
304304
sockopt_impl!(
305305
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
306+
/// Used to disable Nagle's algorithm.
307+
///
308+
/// Nagle's algorithm:
309+
///
306310
/// Under most circumstances, TCP sends data when it is presented; when
307311
/// outstanding data has not yet been acknowledged, it gathers small amounts
308312
/// of output to be sent in a single packet once an acknowledgement is
309313
/// received. For a small number of clients, such as window systems that
310314
/// send a stream of mouse events which receive no replies, this
311-
/// packetization may cause significant delays. The boolean option
312-
/// TCP_NODELAY defeats this algorithm.
315+
/// packetization may cause significant delays. The boolean option, when
316+
/// enabled, defeats this algorithm.
313317
TcpNoDelay,
314318
Both,
315319
libc::IPPROTO_TCP,
316320
libc::TCP_NODELAY,
317321
bool
318322
);
319323
sockopt_impl!(
320-
/// When enabled, a close(2) or shutdown(2) will not return until all
324+
/// When enabled, a close(2) or shutdown(2) will not return until all
321325
/// queued messages for the socket have been successfully sent or the
322326
/// linger timeout has been reached.
323327
Linger,

src/unistd.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,13 +1002,14 @@ pub fn chown<P: ?Sized + NixPath>(
10021002
Errno::result(res).map(drop)
10031003
}
10041004

1005-
/// Change the ownership of the file referred to by the open file descriptor `fd` to be owned by
1006-
/// the specified `owner` (user) and `group` (see
1007-
/// [fchown(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchown.html)).
1005+
/// Change the ownership of the file referred to by the open file descriptor
1006+
/// `fd` to be owned by the specified `owner` (user) and `group`.
10081007
///
10091008
/// The owner/group for the provided file will not be modified if `None` is
10101009
/// provided for that argument. Ownership change will be attempted for the path
10111010
/// only if `Some` owner/group is provided.
1011+
///
1012+
/// See also [`fchown(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchown.html).
10121013
#[inline]
10131014
pub fn fchown<Fd: std::os::fd::AsFd>(fd: Fd, owner: Option<Uid>, group: Option<Gid>) -> Result<()> {
10141015
use std::os::fd::AsRawFd;
@@ -1303,19 +1304,22 @@ pub fn sethostname<S: AsRef<OsStr>>(name: S) -> Result<()> {
13031304
}
13041305

13051306
/// Get the host name and store it in an internally allocated buffer, returning an
1306-
/// `OsString` on success (see
1307-
/// [gethostname(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html)).
1307+
/// `OsString` on success.
13081308
///
13091309
/// This function call attempts to get the host name for the running system and
13101310
/// store it in an internal buffer, returning it as an `OsString` if successful.
13111311
///
1312+
/// # Examples
1313+
///
13121314
/// ```no_run
13131315
/// use nix::unistd;
13141316
///
13151317
/// let hostname = unistd::gethostname().expect("Failed getting hostname");
13161318
/// let hostname = hostname.into_string().expect("Hostname wasn't valid UTF-8");
13171319
/// println!("Hostname: {}", hostname);
13181320
/// ```
1321+
///
1322+
/// See also [gethostname(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html).
13191323
pub fn gethostname() -> Result<OsString> {
13201324
// The capacity is the max length of a hostname plus the NUL terminator.
13211325
let mut buffer: Vec<u8> = Vec::with_capacity(256);

test/test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ fn read_exact<Fd: AsFd>(f: Fd, buf: &mut [u8]) {
6060
}
6161
}
6262

63-
/// Any test that creates child processes or can be affected by child processes must grab this mutex, regardless
64-
/// of what it does with those children. It must hold the mutex until the
65-
/// child processes are waited upon.
63+
/// Any test that creates child processes or can be affected by child processes
64+
/// must grab this mutex, regardless of what it does with those children.
65+
///
66+
/// It must hold the mutex until the child processes are waited upon.
6667
pub static FORK_MTX: Mutex<()> = Mutex::new(());
6768
/// Any test that changes the process's current working directory must grab
6869
/// the RwLock exclusively. Any process that cares about the current

0 commit comments

Comments
 (0)