The following code gets the page size from sysconf to optimally read files from the filesystem. I am unable to create the buffer with the size:
lazy_static! {
static ref PAGE_SIZE: i64 = sysconf(SysconfVariable::ScPagesize).unwrap();
}
fn main() {
let mut buffer = [0; *PAGE_SIZE as usize];
}
Gives me:
error[E0080]: constant evaluation error
--> src/main.rs:6:30
|
6 | let mut buffer = [0; *PAGE_SIZE as usize];
| ^^^^^^^^^^ unimplemented constant expression: deref operation
I thought it is a operator priority problem and tried to wrap with it braces but the result still the same:
error[E0080]: constant evaluation error
--> src/main.rs:6:30
|
6 | let mut buffer = [0; (*(PAGE_SIZE)) as usize];
| ^^^^^^^^^^^^^^ unimplemented constant expression: deref operation
How to use the constant above for allocating a buffer?