mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
js: fix rand
build, properly use key values on map, add rand.string
(#12020)
This commit is contained in:
@ -125,3 +125,16 @@ pub fn hex(len int) string {
|
||||
pub fn ascii(len int) string {
|
||||
return string_from_set(ascii_chars, len)
|
||||
}
|
||||
|
||||
fn deinit() {
|
||||
unsafe {
|
||||
default_rng.free() // free the implementation
|
||||
free(default_rng) // free the interface wrapper itself
|
||||
}
|
||||
}
|
||||
|
||||
// init initializes the default RNG.
|
||||
fn init() {
|
||||
default_rng = new_default()
|
||||
C.atexit(deinit)
|
||||
}
|
||||
|
Reference in New Issue
Block a user