fix(resultsrange): use usize min instead of usize max
All checks were successful
Build and Test / build-editions (wii-u-chat) (push) Successful in 3m7s
Build and Test / build-editions (minecraft-wiiu) (push) Successful in 3m44s
Build and Test / build-editions (DATABASE_FRIENDS, friends) (push) Successful in 3m45s
Build and Test / build-editions (sonic-transformed) (push) Successful in 4m28s
Build and Test / build-editions (terraria) (push) Successful in 5m44s
Build and Test / build-editions (fast-racing-neo) (push) Successful in 6m0s
Build and Test / build-editions (mario-tennis) (push) Successful in 6m24s
Build and Test / build-editions (splatoon-testfire) (push) Successful in 6m27s
Build and Test / build-editions (DATABASE_SMM, super-mario-maker) (push) Successful in 6m31s
Build and Test / build-editions (DATABASE_SMM, wii-sports-club) (push) Successful in 6m36s
Build and Test / build-editions (DATABASE_SMM, puyopuyo) (push) Successful in 6m37s
Build and Test / build-editions (splatoon) (push) Successful in 6m56s
All checks were successful
Build and Test / build-editions (wii-u-chat) (push) Successful in 3m7s
Build and Test / build-editions (minecraft-wiiu) (push) Successful in 3m44s
Build and Test / build-editions (DATABASE_FRIENDS, friends) (push) Successful in 3m45s
Build and Test / build-editions (sonic-transformed) (push) Successful in 4m28s
Build and Test / build-editions (terraria) (push) Successful in 5m44s
Build and Test / build-editions (fast-racing-neo) (push) Successful in 6m0s
Build and Test / build-editions (mario-tennis) (push) Successful in 6m24s
Build and Test / build-editions (splatoon-testfire) (push) Successful in 6m27s
Build and Test / build-editions (DATABASE_SMM, super-mario-maker) (push) Successful in 6m31s
Build and Test / build-editions (DATABASE_SMM, wii-sports-club) (push) Successful in 6m36s
Build and Test / build-editions (DATABASE_SMM, puyopuyo) (push) Successful in 6m37s
Build and Test / build-editions (splatoon) (push) Successful in 6m56s
This commit is contained in:
parent
3db244c2ff
commit
be7bc79762
3 changed files with 22 additions and 6 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2459,6 +2459,7 @@ dependencies = [
|
||||||
name = "rnex-base-protos"
|
name = "rnex-base-protos"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
"ctor",
|
"ctor",
|
||||||
"rnex-rmc",
|
"rnex-rmc",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
cfg-if = "1.0.4"
|
||||||
ctor = "1.0.8"
|
ctor = "1.0.8"
|
||||||
rnex-rmc = { path = "../../rnex-rmc" }
|
rnex-rmc = { path = "../../rnex-rmc" }
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ pub mod secure;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
use secure::{RawSecure, RawSecureInfo, RemoteSecure, Secure};
|
use secure::{RawSecure, RawSecureInfo, RemoteSecure, Secure};
|
||||||
use util::{RawUtility, RawUtilityInfo, RemoteUtility, Utility};
|
use util::{RawUtility, RawUtilityInfo, RemoteUtility, Utility};
|
||||||
|
use cfg_if::cfg_if;
|
||||||
|
|
||||||
#[derive(RmcSerialize, Debug, Default, Clone)]
|
#[derive(RmcSerialize, Debug, Default, Clone)]
|
||||||
#[rmc_struct(0)]
|
#[rmc_struct(0)]
|
||||||
|
|
@ -13,13 +14,26 @@ pub struct ResultsRange {
|
||||||
pub size: u32,
|
pub size: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResultsRange {
|
cfg_if! {
|
||||||
pub fn make_from_list<T: Clone>(&self, list: &[T]) -> Vec<T> {
|
if #[cfg(feature = "v3-8-13")] {
|
||||||
let end = usize::max(list.len(), self.offset as usize + self.size as usize);
|
impl ResultsRange {
|
||||||
|
pub fn make_from_list<T: Clone>(&self, list: &[T]) -> Vec<T> {
|
||||||
|
let start = (self.offset as usize).min(list.len());
|
||||||
|
let end = (start + self.size as usize).min(list.len());
|
||||||
|
|
||||||
list.get(self.offset as usize..end)
|
list[start..end].to_vec()
|
||||||
.unwrap_or_default()
|
}
|
||||||
.into()
|
}
|
||||||
|
} else {
|
||||||
|
impl ResultsRange {
|
||||||
|
pub fn make_from_list<T: Clone>(&self, list: &[T]) -> Vec<T> {
|
||||||
|
let end = usize::max(list.len(), self.offset as usize + self.size as usize);
|
||||||
|
|
||||||
|
list.get(self.offset as usize..end)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue