@@ -16,13 +16,14 @@ extern crate tendril;
1616
1717use std:: borrow:: ToOwned ;
1818
19- use rand:: distributions:: { IndependentSample , Range } ;
19+ use rand:: distr:: uniform:: Uniform as Range ;
20+ use rand:: distr:: Distribution ;
2021use rand:: Rng ;
2122use tendril:: StrTendril ;
2223
2324fn fuzz ( ) {
24- let mut rng = rand:: thread_rng ( ) ;
25- let capacity = Range :: new ( 0u32 , 1 << 14 ) . ind_sample ( & mut rng) ;
25+ let mut rng = rand:: rng ( ) ;
26+ let capacity = Range :: new ( 0u32 , 1 << 14 ) . unwrap ( ) . sample ( & mut rng) ;
2627 let mut buf_string = String :: with_capacity ( capacity as usize ) ;
2728 let mut buf_tendril = StrTendril :: with_capacity ( capacity) ;
2829 let mut string_slices = vec ! [ ] ;
@@ -34,8 +35,8 @@ fn fuzz() {
3435 buf_tendril. clear ( ) ;
3536 }
3637
37- let dist_action = Range :: new ( 0 , 100 ) ;
38- match dist_action. ind_sample ( & mut rng) {
38+ let dist_action = Range :: new ( 0 , 100 ) . unwrap ( ) ;
39+ match dist_action. sample ( & mut rng) {
3940 0 ..=15 => {
4041 let ( start, end) = random_slice ( & mut rng, TEXT ) ;
4142 let snip = & TEXT [ start..end] ;
@@ -82,7 +83,7 @@ fn fuzz() {
8283 } ,
8384
8485 91 ..=96 => {
85- let c = rng. gen ( ) ;
86+ let c = rng. random ( ) ;
8687 buf_string. push ( c) ;
8788 assert ! ( buf_tendril. try_push_char( c) . is_ok( ) ) ;
8889 assert_eq ! ( & * buf_string, & * buf_tendril) ;
@@ -110,7 +111,7 @@ fn fuzz() {
110111
111112fn random_boundary < R : Rng > ( rng : & mut R , text : & str ) -> usize {
112113 loop {
113- let i = Range :: new ( 0 , text. len ( ) + 1 ) . ind_sample ( rng) ;
114+ let i = Range :: new ( 0 , text. len ( ) + 1 ) . unwrap ( ) . sample ( rng) ;
114115 if text. is_char_boundary ( i) {
115116 return i;
116117 }
@@ -119,8 +120,8 @@ fn random_boundary<R: Rng>(rng: &mut R, text: &str) -> usize {
119120
120121fn random_slice < R : Rng > ( rng : & mut R , text : & str ) -> ( usize , usize ) {
121122 loop {
122- let start = Range :: new ( 0 , text. len ( ) + 1 ) . ind_sample ( rng) ;
123- let end = Range :: new ( start, text. len ( ) + 1 ) . ind_sample ( rng) ;
123+ let start = Range :: new ( 0 , text. len ( ) + 1 ) . unwrap ( ) . sample ( rng) ;
124+ let end = Range :: new ( start, text. len ( ) + 1 ) . unwrap ( ) . sample ( rng) ;
124125 if !text. is_char_boundary ( start) {
125126 continue ;
126127 }
0 commit comments