File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 5d84652f511d68f401493284c82525cdabe2fafb
2
+ refs/heads/master: af415647475b30e296ce7ef26abb9ec63d2458e6
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ type rng = obj {
39
39
Return a random string composed of A-Z, a-z, 0-9.
40
40
*/
41
41
fn gen_str ( len : uint ) -> str ;
42
+
43
+ /*
44
+ Method: gen_bytes
45
+
46
+ Return a random byte string.
47
+ */
48
+ fn gen_bytes ( len : uint ) -> [ u8 ] ;
42
49
} ;
43
50
44
51
resource rand_res( c: rustrt:: rctx) { rustrt:: rand_free ( c) ; }
@@ -74,6 +81,16 @@ fn mk_rng() -> rng {
74
81
}
75
82
s
76
83
}
84
+ fn gen_bytes ( len : uint ) -> [ u8 ] {
85
+ let v = [ ] ;
86
+ let i = 0 u;
87
+ while i < len {
88
+ let n = rustrt:: rand_next ( * * c) as uint ;
89
+ v += [ ( n % ( u8:: max_value as uint ) ) as u8 ] ;
90
+ i += 1 u;
91
+ }
92
+ v
93
+ }
77
94
}
78
95
ret rt_rng( @rand_res ( rustrt:: rand_new ( ) ) ) ;
79
96
}
You can’t perform that action at this time.
0 commit comments