master > master: code-rust - minor

This commit is contained in:
RD 2022-04-08 17:07:03 +02:00
parent 2f600e01e3
commit 2f4032b64a
1 changed files with 9 additions and 3 deletions

View File

@ -31,7 +31,7 @@ pub fn min<T>(x: T, y: T) -> T
// METHODS Vectors
// ----------------------------------------------------------------
pub fn restrict<T>(x: &mut Vec<T>, i: usize, j: usize) -> Vec<T>
pub fn restrict<T>(x: &Vec<T>, i: usize, j: usize) -> Vec<T>
where T: Clone
{
return x[i..j].iter()
@ -39,17 +39,23 @@ pub fn restrict<T>(x: &mut Vec<T>, i: usize, j: usize) -> Vec<T>
.collect::<Vec<T>>();
}
pub fn remove_last<T>(x: &mut Vec<T>) -> Vec<T>
pub fn remove_last<T>(x: &Vec<T>) -> Vec<T>
where T: Clone
{
let n = x.len();
if n == 0 {
return Vec::<T>::new();
}
return restrict::<T>(x, 0, n-1);
}
#[allow(dead_code)]
pub fn remove_first<T>(x: &mut Vec<T>) -> Vec<T>
pub fn remove_first<T>(x: &Vec<T>) -> Vec<T>
where T: Clone
{
let n = x.len();
if n == 0 {
return Vec::<T>::new();
}
return restrict::<T>(x, 0, n);
}