mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-17 23:19:06 +00:00
Improve commentary on collisions in pastebin example.
This commit is contained in:
parent
527051d136
commit
3a76fe03db
@ -14,8 +14,8 @@ pub struct PasteID<'a>(Cow<'a, str>);
|
|||||||
impl<'a> PasteID<'a> {
|
impl<'a> PasteID<'a> {
|
||||||
/// Generate a _probably_ unique ID with `size` characters. For readability,
|
/// Generate a _probably_ unique ID with `size` characters. For readability,
|
||||||
/// the characters used are from the sets [0-9], [A-Z], [a-z]. The
|
/// the characters used are from the sets [0-9], [A-Z], [a-z]. The
|
||||||
/// probability of a collision depends on the value of `size`. In
|
/// probability of a collision depends on the value of `size` and the number
|
||||||
/// particular, the probability of a collision is 1/62^(size).
|
/// of IDs generated thus far.
|
||||||
pub fn new(size: usize) -> PasteID<'static> {
|
pub fn new(size: usize) -> PasteID<'static> {
|
||||||
let mut id = String::with_capacity(size);
|
let mut id = String::with_capacity(size);
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
@ -145,8 +145,8 @@ pub struct PasteID<'a>(Cow<'a, str>);
|
|||||||
impl<'a> PasteID<'a> {
|
impl<'a> PasteID<'a> {
|
||||||
/// Generate a _probably_ unique ID with `size` characters. For readability,
|
/// Generate a _probably_ unique ID with `size` characters. For readability,
|
||||||
/// the characters used are from the sets [0-9], [A-Z], [a-z]. The
|
/// the characters used are from the sets [0-9], [A-Z], [a-z]. The
|
||||||
/// probability of a collision depends on the value of `size`. In
|
/// probability of a collision depends on the value of `size` and the number
|
||||||
/// particular, the probability of a collision is 1/62^(size).
|
/// of IDs generated thus far.
|
||||||
pub fn new(size: usize) -> PasteID<'static> {
|
pub fn new(size: usize) -> PasteID<'static> {
|
||||||
let mut id = String::with_capacity(size);
|
let mut id = String::with_capacity(size);
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
Loading…
Reference in New Issue
Block a user