Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 869 Bytes

File metadata and controls

66 lines (43 loc) · 869 Bytes

Standard Library: Env (std/env.zc)

Env is a Zen-C library for accessing the environment of the process environment.

Usage

import "std/env.zc"

fn main() {
    Env::set("HELLO", "world");

    let hello = Env::get("HELLO");

    if (hello.is_some()) {
        println "Hello {hello.unwrap()}";
    }
}

Enum

enum EnvRes {
    ERR,
    OK,
}

Methods

get

Retrieves the env-variable as borrowed string (char *) (no alloc)

fn get(name: string) -> Option<string>

get_dup

Retrieves the env-variable as caller-owned String() (heap alloc)

fn get_dup(name: string) -> Option<String>

set

Sets an env-variable

fn set(name: string, value: string) -> EnvRes

unset

Unsets an existing env-variable

fn unset(name: string) -> EnvRes

Check the examples folder for more.