Skip to content

Commit f15bba3

Browse files
authored
Document which functions require std (#591)
1 parent c93a94b commit f15bba3

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
steps:
158158
- uses: actions/checkout@v3
159159
- name: Install Rust
160-
run: rustup update stable && rustup default stable
160+
run: rustup update $nightly && rustup default $nightly
161161
- name: Build documentation
162162
run: cargo doc --no-deps --all-features
163163
env:

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ Serde support is optional and disabled by default. To enable use the feature `se
3636
bytes = { version = "1", features = ["serde"] }
3737
```
3838

39+
## Building documentation
40+
41+
When building the `bytes` documentation the `docsrs` option should be used, otherwise
42+
feature gates will not be shown. This requires a nightly toolchain:
43+
44+
```
45+
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc
46+
```
47+
3948
## License
4049

4150
This project is licensed under the [MIT license](LICENSE).

src/buf/buf_impl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub trait Buf {
160160
///
161161
/// [`writev`]: http://man7.org/linux/man-pages/man2/readv.2.html
162162
#[cfg(feature = "std")]
163+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
163164
fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize {
164165
if dst.is_empty() {
165166
return 0;
@@ -1183,6 +1184,7 @@ pub trait Buf {
11831184
/// assert_eq!(&dst[..11], &b"hello world"[..]);
11841185
/// ```
11851186
#[cfg(feature = "std")]
1187+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
11861188
fn reader(self) -> Reader<Self>
11871189
where
11881190
Self: Sized,

src/buf/buf_mut.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ pub unsafe trait BufMut {
12391239
/// assert_eq!(*buf, b"hello world"[..]);
12401240
/// ```
12411241
#[cfg(feature = "std")]
1242+
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
12421243
fn writer(self) -> Writer<Self>
12431244
where
12441245
Self: Sized,

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
55
))]
66
#![no_std]
7+
#![cfg_attr(docsrs, feature(doc_cfg))]
78

89
//! Provides abstractions for working with bytes.
910
//!

0 commit comments

Comments
 (0)