Skip to content

Commit 3bd7ccd

Browse files
committed
update MSRV to 1.70, use OnceLock, remove doc_auto_cfg
1 parent cda51bc commit 3bd7ccd

File tree

7 files changed

+21
-141
lines changed

7 files changed

+21
-141
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,10 @@ jobs:
4646
strategy:
4747
matrix:
4848
os: [ ubuntu-latest ]
49-
# 1.39 is the MSRV
50-
# The rest correspond to version gating in build.rs.
49+
# 1.70 is the MSRV
5150
rust-version:
52-
- version: 1.39
53-
build-features-excluded: 'tokio1'
54-
- version: 1.51
55-
build-features-excluded: ''
56-
- version: 1.61
57-
build-features-excluded: ''
58-
- version: stable
59-
build-features-excluded: ''
51+
- "1.70"
52+
- stable
6053
fail-fast: false
6154
env:
6255
RUSTFLAGS: -D warnings
@@ -73,11 +66,11 @@ jobs:
7366
cargo hack build --feature-powerset \
7467
--exclude-features "${{ matrix.rust-version.build-features-excluded }}"
7568
- name: Test
76-
# Dev dependencies have an MSRV > 1.39.
69+
# Dev dependencies have an MSRV > 1.70.
7770
if: ${{ matrix.rust-version.version == 'stable' }}
7871
run: cargo hack test --feature-powerset
7972
- name: Test with updated Cargo.lock
80-
# Dev dependencies have an MSRV > 1.39.
73+
# Dev dependencies have an MSRV > 1.70.
8174
if: ${{ matrix.rust-version.version == 'stable' }}
8275
run: |
8376
cargo update

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ readme = "README.md"
1010
repository = "https://github.com/sunshowers-code/buf-list"
1111
rust-version = "1.39"
1212

13+
[lints]
14+
rust.unexpected_cfgs = { level = "warn", check-cfg = ["cfg(doc_cfg)"] }
15+
1316
[package.metadata.docs.rs]
1417
all-features = true
1518
rustdoc-args = ["--cfg=doc_cfg"]
1619

1720
[dependencies]
1821
bytes = "1.3.0"
1922
futures-io-03 = { package = "futures-io", version = "0.3.25", optional = true }
20-
once_cell = "1.4.0"
2123
tokio = { version = "1.0.0", features = ["io-std"], optional = true }
2224

2325
[dev-dependencies]

build.rs

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/cursor/mod.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,10 @@ impl<T: AsRef<BufList>> Cursor<T> {
8383
///
8484
/// let reference = cursor.get_ref();
8585
/// ```
86-
#[cfg(const_fn_trait_bounds)]
8786
pub const fn get_ref(&self) -> &T {
8887
&self.inner
8988
}
9089

91-
/// Gets a reference to the underlying value in this cursor.
92-
///
93-
/// # Examples
94-
///
95-
/// ```
96-
/// use buf_list::{BufList, Cursor};
97-
///
98-
/// let cursor = Cursor::new(BufList::new());
99-
///
100-
/// let reference = cursor.get_ref();
101-
/// ```
102-
#[cfg(not(const_fn_trait_bounds))]
103-
pub fn get_ref(&self) -> &T {
104-
&self.inner
105-
}
106-
10790
/// Returns the current position of this cursor.
10891
///
10992
/// # Examples
@@ -123,35 +106,10 @@ impl<T: AsRef<BufList>> Cursor<T> {
123106
/// cursor.seek(SeekFrom::Current(-1)).unwrap();
124107
/// assert_eq!(cursor.position(), 1);
125108
/// ```
126-
#[cfg(const_fn_trait_bounds)]
127109
pub const fn position(&self) -> u64 {
128110
self.data.pos
129111
}
130112

131-
/// Returns the current position of this cursor.
132-
///
133-
/// # Examples
134-
///
135-
/// ```
136-
/// use buf_list::{BufList, Cursor};
137-
/// use std::io::prelude::*;
138-
/// use std::io::SeekFrom;
139-
///
140-
/// let mut cursor = Cursor::new(BufList::from(&[1, 2, 3, 4, 5][..]));
141-
///
142-
/// assert_eq!(cursor.position(), 0);
143-
///
144-
/// cursor.seek(SeekFrom::Current(2)).unwrap();
145-
/// assert_eq!(cursor.position(), 2);
146-
///
147-
/// cursor.seek(SeekFrom::Current(-1)).unwrap();
148-
/// assert_eq!(cursor.position(), 1);
149-
/// ```
150-
#[cfg(not(const_fn_trait_bounds))]
151-
pub fn position(&self) -> u64 {
152-
self.data.pos
153-
}
154-
155113
/// Sets the position of this cursor.
156114
///
157115
/// # Examples
@@ -206,7 +164,6 @@ impl<T: AsRef<BufList>> io::Seek for Cursor<T> {
206164
self.data.seek_impl(self.inner.as_ref(), style)
207165
}
208166

209-
#[cfg(seek_convenience)]
210167
fn stream_position(&mut self) -> io::Result<u64> {
211168
Ok(self.data.pos)
212169
}
@@ -366,7 +323,7 @@ impl CursorData {
366323
Ok(())
367324
}
368325

369-
fn fill_buf_impl<'a>(&'a self, list: &'a BufList) -> &[u8] {
326+
fn fill_buf_impl<'a>(&'a self, list: &'a BufList) -> &'a [u8] {
370327
const EMPTY_SLICE: &[u8] = &[];
371328
match self.get_chunk_and_pos(list) {
372329
Some((chunk, chunk_pos)) => &chunk.as_ref()[chunk_pos..],

src/imp.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
use bytes::{Buf, BufMut, Bytes, BytesMut};
6-
use once_cell::sync::OnceCell;
76
use std::{
87
collections::VecDeque,
98
io::IoSlice,
109
iter::{FromIterator, FusedIterator},
10+
sync::OnceLock,
1111
};
1212

1313
/// Data composed of a list of [`Bytes`] chunks.
@@ -20,7 +20,7 @@ pub struct BufList {
2020

2121
/// An index of chunks and their start positions. There's an additional index at the end, which
2222
/// is the length of the list (list.num_bytes()).
23-
start_pos: OnceCell<Box<[u64]>>,
23+
start_pos: OnceLock<Box<[u64]>>,
2424
}
2525

2626
impl BufList {
@@ -50,7 +50,7 @@ impl BufList {
5050
pub fn with_capacity(capacity: usize) -> Self {
5151
Self {
5252
bufs: VecDeque::with_capacity(capacity),
53-
start_pos: OnceCell::new(),
53+
start_pos: OnceLock::new(),
5454
}
5555
}
5656

@@ -133,8 +133,8 @@ impl BufList {
133133
/// assert_eq!(buf_list.num_chunks(), 2);
134134
/// ```
135135
pub fn push_chunk<B: Buf>(&mut self, mut data: B) -> Bytes {
136-
// mutable borrow acquired, invalidate oncecell
137-
self.start_pos = OnceCell::new();
136+
// mutable borrow acquired, invalidate the OnceLock
137+
self.start_pos = OnceLock::new();
138138

139139
let len = data.remaining();
140140
// `data` is (almost) certainly a `Bytes`, so `copy_to_bytes` should
@@ -155,8 +155,8 @@ impl BufList {
155155

156156
impl<B: Buf> Extend<B> for BufList {
157157
fn extend<T: IntoIterator<Item = B>>(&mut self, iter: T) {
158-
// mutable borrow acquired, invalidate oncecell
159-
self.start_pos = OnceCell::new();
158+
// mutable borrow acquired, invalidate the OnceLock
159+
self.start_pos = OnceLock::new();
160160

161161
for buf in iter.into_iter() {
162162
self.push_chunk(buf);
@@ -231,8 +231,8 @@ impl Buf for BufList {
231231
}
232232

233233
fn advance(&mut self, mut amt: usize) {
234-
// mutable borrow acquired, invalidate oncecell
235-
self.start_pos = OnceCell::new();
234+
// mutable borrow acquired, invalidate the OnceLock
235+
self.start_pos = OnceLock::new();
236236

237237
while amt > 0 {
238238
let rem = self.bufs[0].remaining();
@@ -254,8 +254,8 @@ impl Buf for BufList {
254254
}
255255

256256
fn copy_to_bytes(&mut self, len: usize) -> Bytes {
257-
// mutable borrow acquired, invalidate oncecell
258-
self.start_pos = OnceCell::new();
257+
// mutable borrow acquired, invalidate the OnceLock
258+
self.start_pos = OnceLock::new();
259259

260260
// If the length of the requested `Bytes` is <= the length of the front
261261
// buffer, we can just use its `copy_to_bytes` implementation (which is

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
#![forbid(unsafe_code)]
66
#![warn(missing_docs)]
7-
#![cfg_attr(doc_cfg, feature(doc_cfg, doc_auto_cfg, doc_cfg_hide))]
8-
#![cfg_attr(doc_cfg, doc(cfg_hide(const_fn_trait_bounds)))]
7+
#![cfg_attr(doc_cfg, feature(doc_cfg))]
98

109
//! A segmented list of [`bytes::Bytes`] chunks.
1110
//!

0 commit comments

Comments
 (0)