Skip to content

Commit

Permalink
Merge pull request #82 from c410-f3r/misc
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
c410-f3r authored Sep 11, 2024
2 parents 03fc85b + e1043bb commit fde888c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-07-10
toolchain: nightly-2024-09-07
- uses: actions-rs/[email protected]
with:
crate: cargo-fuzz
Expand All @@ -31,7 +31,7 @@ jobs:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2024-07-10
toolchain: nightly-2024-09-07
- uses: Swatinem/rust-cache@v2

- run: .scripts/all.sh
44 changes: 25 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 25 additions & 25 deletions cl-aux/src/traits/with_capacity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ where
type Input;

/// Creates a new instance based on an initial holding capacity provided by `Input`.
fn with_capacity(input: Self::Input) -> Self;
fn with_capacity(input: Self::Input) -> Result<Self, Self::Error>;
}

/// ```rust
/// use cl_aux::Capacity;
/// let structure: [i32; 5];
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
impl<T, const N: usize> WithCapacity for [T; N]
Expand All @@ -29,13 +29,13 @@ where
type Input = usize;

#[inline]
fn with_capacity(_: Self::Input) -> Self {
[(); N].map(|_| T::default())
fn with_capacity(_: Self::Input) -> Result<Self, Self::Error> {
Ok([(); N].map(|_| T::default()))
}
}

/// ```rust
/// let structure: String = cl_aux::WithCapacity::with_capacity(2);
/// let structure: String = cl_aux::WithCapacity::with_capacity(2).unwrap();
/// assert_eq!(structure.capacity(), 2);
/// ```
#[cfg(feature = "alloc")]
Expand All @@ -44,13 +44,13 @@ impl WithCapacity for String {
type Input = usize;

#[inline]
fn with_capacity(input: Self::Input) -> Self {
String::with_capacity(input)
fn with_capacity(input: Self::Input) -> Result<Self, Self::Error> {
Ok(String::with_capacity(input))
}
}

/// ```rust
/// let structure: Vec<i32> = cl_aux::WithCapacity::with_capacity(2);
/// let structure: Vec<i32> = cl_aux::WithCapacity::with_capacity(2).unwrap();
/// assert_eq!(structure.capacity(), 2);
/// ```
#[cfg(feature = "alloc")]
Expand All @@ -59,14 +59,14 @@ impl<T> WithCapacity for Vec<T> {
type Input = usize;

#[inline]
fn with_capacity(input: Self::Input) -> Self {
Vec::with_capacity(input)
fn with_capacity(input: Self::Input) -> Result<Self, Self::Error> {
Ok(Vec::with_capacity(input))
}
}

/// ```rust
/// let structure: arrayvec::ArrayString<5>;
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
#[cfg(feature = "arrayvec")]
Expand All @@ -75,14 +75,14 @@ impl<const N: usize> WithCapacity for arrayvec::ArrayString<N> {
type Input = usize;

#[inline]
fn with_capacity(_: Self::Input) -> Self {
arrayvec::ArrayString::new()
fn with_capacity(_: Self::Input) -> Result<Self, Self::Error> {
Ok(arrayvec::ArrayString::new())
}
}

/// ```rust
/// let structure: arrayvec::ArrayVec<i32, 5>;
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
#[cfg(feature = "arrayvec")]
Expand All @@ -91,14 +91,14 @@ impl<T, const N: usize> WithCapacity for arrayvec::ArrayVec<T, N> {
type Input = usize;

#[inline]
fn with_capacity(_: Self::Input) -> Self {
arrayvec::ArrayVec::new()
fn with_capacity(_: Self::Input) -> Result<Self, Self::Error> {
Ok(arrayvec::ArrayVec::new())
}
}

/// ```rust
/// let structure: smallvec::SmallVec<[i32; 5]>;
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
#[cfg(feature = "smallvec")]
Expand All @@ -110,14 +110,14 @@ where
type Input = usize;

#[inline]
fn with_capacity(input: Self::Input) -> Self {
smallvec::SmallVec::with_capacity(input)
fn with_capacity(input: Self::Input) -> Result<Self, Self::Error> {
Ok(smallvec::SmallVec::with_capacity(input))
}
}

/// ```rust
/// let mut structure = cl_aux::doc_tests::tiny_vec_array_vec();
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
#[cfg(feature = "tinyvec")]
Expand All @@ -130,14 +130,14 @@ where
type Input = usize;

#[inline]
fn with_capacity(_: Self::Input) -> Self {
tinyvec::ArrayVec::new()
fn with_capacity(_: Self::Input) -> Result<Self, Self::Error> {
Ok(tinyvec::ArrayVec::new())
}
}

/// ```rust
/// let mut structure = cl_aux::doc_tests::tiny_vec_tiny_vec();
/// structure = cl_aux::WithCapacity::with_capacity(0);
/// structure = cl_aux::WithCapacity::with_capacity(0).unwrap();
/// assert_eq!(structure.capacity(), 5);
/// ```
#[cfg(all(feature = "alloc", feature = "tinyvec"))]
Expand All @@ -150,7 +150,7 @@ where
type Input = usize;

#[inline]
fn with_capacity(input: Self::Input) -> Self {
tinyvec::TinyVec::with_capacity(input)
fn with_capacity(input: Self::Input) -> Result<Self, Self::Error> {
Ok(tinyvec::TinyVec::with_capacity(input))
}
}
13 changes: 6 additions & 7 deletions ndstruct/src/csl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ where
/// let _ = CslVec::<i32, 3>::with_capacity(nnz, nolp1);
/// ```
#[inline]
#[must_use]
pub fn with_capacity(nnz: usize, nolp1: usize) -> Self {
Self {
data: DS::with_capacity(nnz),
pub fn with_capacity(nnz: usize, nolp1: usize) -> crate::Result<Self> {
Ok(Self {
data: DS::with_capacity(nnz)?,
dims: <_>::default(),
indcs: IS::with_capacity(nnz),
offs: OS::with_capacity(nolp1),
}
indcs: IS::with_capacity(nnz)?,
offs: OS::with_capacity(nolp1)?,
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-07-10"
channel = "nightly-2024-09-07"
components = ["clippy", "miri", "rustfmt"]
profile = "minimal"
2 changes: 1 addition & 1 deletion rust-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ rust-tools --file SOME_CONFIGURATION_FILE.cfg SOME_COMMAND
add_clipy_flags -Aclippy::type_complexity
rm_clippy_flags -Aclippy::implicit_return,-Aclippy::missing_docs_in_private_items
template you-rust
toolchain nightly-2024-07-10
toolchain nightly-2024-09-07
```

## CLI parameters
Expand Down
6 changes: 5 additions & 1 deletion rust-tools/src/cfg/you_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ const CLIPPY_FLAGS: &[&str] = &[
"-Aclippy::allow_attributes",
"-Aclippy::big_endian_bytes",
"-Aclippy::blanket-clippy-restriction-lints",
"-Aclippy::copy_iterator",
"-Aclippy::decimal_literal_representation",
"-Aclippy::default_numeric_fallback",
"-Aclippy::else_if_without_else",
"-Aclippy::enum_variant_names",
"-Aclippy::error_impl_error",
"-Aclippy::exhaustive_enums",
"-Aclippy::exhaustive_structs",
Expand All @@ -34,7 +37,6 @@ const CLIPPY_FLAGS: &[&str] = &[
"-Aclippy::multiple_inherent_impl",
"-Aclippy::must_use_candidate",
"-Aclippy::needless_doctest_main",
"-Aclippy::panic_in_result_fn",
"-Aclippy::pattern_type_mismatch",
"-Aclippy::pub_use",
"-Aclippy::pub_with_shorthand",
Expand All @@ -45,6 +47,8 @@ const CLIPPY_FLAGS: &[&str] = &[
"-Aclippy::similar_names",
"-Aclippy::single_call_fn",
"-Aclippy::struct_field_names",
"-Aclippy::too_long_first_doc_paragraph",
"-Aclippy::unneeded_field_pattern",
"-Aclippy::unseparated_literal_suffix",
"-Aclippy::used_underscore_binding",
"-Aclippy::wildcard_enum_match_arm",
Expand Down
4 changes: 2 additions & 2 deletions rust-tools/src/parse_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mod tests {
rm_rust_flags E
add_rustfmt_flags F
template you-rust
toolchain nightly-2024-07-10
toolchain nightly-2024-09-07
"#;
let (params, tp) = parse_cfg(&cfg[..]).unwrap();
assert_eq!(params, YouRust::default().0);
Expand All @@ -111,6 +111,6 @@ mod tests {
assert_eq!(tp.rm_rust_flags, vec!["E"]);
assert_eq!(tp.add_rustfmt_flags, vec!["F"]);
assert_eq!(tp.rm_rustfmt_flags, Vec::<String>::new());
assert_eq!(tp.toolchain, "nightly-2024-07-10");
assert_eq!(tp.toolchain, "nightly-2024-09-07");
}
}

0 comments on commit fde888c

Please sign in to comment.