Skip to content

Commit

Permalink
Update the traits.rs test file
Browse files Browse the repository at this point in the history
  • Loading branch information
sonmarcho committed Nov 22, 2023
1 parent 1dbefa6 commit 501bc66
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions tests/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ pub fn test_enumerate(x: usize) {
}
*/

pub fn incr_u32(x: u32) -> u32 {
x + 1
}

/* Custom function pointers */
pub trait CFnOnce<Args> {
type Output;
Expand All @@ -301,6 +297,10 @@ pub trait CFn<Args>: CFnMut<Args> {
fn call_mut(&self, args: Args) -> Self::Output;
}

pub fn incr_u32(x: u32) -> u32 {
x + 1
}

/*
/* Testing function pointers and closures */
// TODO: this requires to take into account the constraints over associated types
Expand All @@ -317,12 +317,19 @@ where
Some(x) => Some(f(x)),
}
}
*/
/*
// With a pointer to a top level function
pub fn test_map_option1(x: Option<u32>) -> Option<u32> {
map_option(x, incr_u32)
}*/

/*
//
pub fn test_closure1<T>(x: &T) -> &T {
//let f: fn(&T) -> &T = |x| x;
let f: fn(u32) -> u32 = |x| x;
//(f)(x)
x
}
*/

Expand All @@ -332,7 +339,6 @@ pub fn test_map_option2(x: Option<u32>) -> Option<u32> {
let f: fn(u32) -> u32 = |x| x + 1;
map_option(x, f)
}
*/
/*
// With a local function which uses local type variables
Expand All @@ -347,3 +353,12 @@ pub fn test_map_option3(x: Option<u32>) -> Option<u32> {
let f: fn(u32) -> u32 = |x| x + 1;
map_option(x, f)
}*/
/*
pub fn map(x: [i32; 256]) -> [i32; 256] {
x.map(|v| v)
}
*/
*/

0 comments on commit 501bc66

Please sign in to comment.