Skip to content

Commit 2149a47

Browse files
authored
Merge pull request #3075 from autonomys/minor-fixes
Minor fixes
2 parents 510da22 + a9c817d commit 2149a47

File tree

2 files changed

+4
-76
lines changed
  • crates
    • subspace-core-primitives/src
    • subspace-proof-of-time/src

2 files changed

+4
-76
lines changed

crates/subspace-core-primitives/src/lib.rs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,77 +1176,3 @@ impl SectorId {
11761176
Some(HistorySize::from(expiration_history_size))
11771177
}
11781178
}
1179-
1180-
/// A Vec<> that enforces the invariant that it cannot be empty.
1181-
#[derive(Debug, Clone, Encode, Decode, Eq, PartialEq)]
1182-
pub struct NonEmptyVec<T>(Vec<T>);
1183-
1184-
/// Error codes for `NonEmptyVec`.
1185-
#[derive(Debug)]
1186-
pub enum NonEmptyVecErr {
1187-
/// Tried to create with an empty Vec
1188-
EmptyVec,
1189-
}
1190-
1191-
#[allow(clippy::len_without_is_empty)]
1192-
impl<T: Clone> NonEmptyVec<T> {
1193-
/// Creates the Vec.
1194-
pub fn new(vec: Vec<T>) -> Result<Self, NonEmptyVecErr> {
1195-
if vec.is_empty() {
1196-
return Err(NonEmptyVecErr::EmptyVec);
1197-
}
1198-
1199-
Ok(Self(vec))
1200-
}
1201-
1202-
/// Creates the Vec with the entry.
1203-
pub fn new_with_entry(entry: T) -> Self {
1204-
Self(vec![entry])
1205-
}
1206-
1207-
/// Returns the number of entries.
1208-
pub fn len(&self) -> usize {
1209-
self.0.len()
1210-
}
1211-
1212-
/// Returns the slice of the entries.
1213-
pub fn as_slice(&self) -> &[T] {
1214-
self.0.as_slice()
1215-
}
1216-
1217-
/// Returns an iterator for the entries.
1218-
pub fn iter(&self) -> Box<dyn Iterator<Item = &T> + '_> {
1219-
Box::new(self.0.iter())
1220-
}
1221-
1222-
/// Returns a mutable iterator for the entries.
1223-
pub fn iter_mut(&mut self) -> Box<dyn Iterator<Item = &mut T> + '_> {
1224-
Box::new(self.0.iter_mut())
1225-
}
1226-
1227-
/// Returns the first entry.
1228-
pub fn first(&self) -> T {
1229-
self.0
1230-
.first()
1231-
.expect("NonEmptyVec::first(): collection cannot be empty")
1232-
.clone()
1233-
}
1234-
1235-
/// Returns the last entry.
1236-
pub fn last(&self) -> T {
1237-
self.0
1238-
.last()
1239-
.expect("NonEmptyVec::last(): collection cannot be empty")
1240-
.clone()
1241-
}
1242-
1243-
/// Adds an entry to the end.
1244-
pub fn push(&mut self, entry: T) {
1245-
self.0.push(entry);
1246-
}
1247-
1248-
/// Returns the entries in the collection.
1249-
pub fn to_vec(self) -> Vec<T> {
1250-
self.0
1251-
}
1252-
}

crates/subspace-proof-of-time/src/aes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! AES related functionality.
22
3-
#[cfg(target_arch = "x86_64")]
3+
#[cfg(all(feature = "std", target_arch = "x86_64"))]
44
mod x86_64;
55

66
#[cfg(not(feature = "std"))]
@@ -9,12 +9,14 @@ extern crate alloc;
99
use aes::cipher::array::Array;
1010
use aes::cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit};
1111
use aes::Aes128;
12+
#[cfg(not(feature = "std"))]
13+
use alloc::vec::Vec;
1214
use subspace_core_primitives::{PotCheckpoints, PotKey, PotOutput, PotSeed};
1315

1416
/// Creates the AES based proof.
1517
#[inline(always)]
1618
pub(crate) fn create(seed: PotSeed, key: PotKey, checkpoint_iterations: u32) -> PotCheckpoints {
17-
#[cfg(target_arch = "x86_64")]
19+
#[cfg(all(feature = "std", target_arch = "x86_64"))]
1820
if std::is_x86_feature_detected!("aes") {
1921
return unsafe { x86_64::create(seed.as_ref(), key.as_ref(), checkpoint_iterations) };
2022
}

0 commit comments

Comments
 (0)