rust_profanos/libs/std/
env.rs1use alloc::{string::String, vec::Vec};
2
3#[derive(Debug, Clone)]
4pub struct Args {
5 argc: usize,
6 argv: Vec<String>,
7}
8
9impl Args {
10 pub fn new(argc: usize, argv: Vec<String>) -> Args {
11 Args {
12 argc,
13 argv
14 }
15 }
16
17 pub fn len(&self) -> usize {
18 self.argc
19 }
20
21 pub fn iter(&self) -> impl Iterator<Item = &String> {
22 self.argv.iter()
23 }
24
25 pub fn collect(&self) -> Vec<String> {
26 self.argv.clone()
27 }
28}
29
30pub(crate) static mut ARGS: Option<Args> = None;
31
32#[allow(static_mut_refs)] pub fn args() -> Args {
34 unsafe {
35 ARGS.clone().unwrap()
36 }
37}