File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22name = " generic-queue"
33version = " 0.1.0"
44authors = [" You <you@example.com>" ]
5+ edition = " 2018"
56
67[dependencies ]
Original file line number Diff line number Diff line change 1+ #![ warn( rust_2018_idioms) ]
2+ #![ allow( elided_lifetimes_in_paths) ]
3+
14pub struct Queue < T > {
25 older : Vec < T > ,
36 younger : Vec < T >
47}
58
69impl < T > Queue < T > {
7- pub fn new ( ) -> Queue < T > {
10+ pub fn new ( ) -> Self {
811 Queue { older : Vec :: new ( ) , younger : Vec :: new ( ) }
912 }
1013
@@ -85,6 +88,6 @@ fn test_generic() {
8588 q. push ( "CAD" ) ; // apparently a Queue<&'static str>
8689 r. push ( 0.74 ) ; // apparently a Queue<f64>
8790
88- q. push ( "BTC" ) ; // Bitcoins per USD, 2017-5
89- r. push ( 2737.7 ) ; // Rust fails to detect irrational exuberance
91+ q. push ( "BTC" ) ; // Bitcoins per USD, 2019-6
92+ r. push ( 13764.0 ) ; // Rust fails to detect irrational exuberance
9093}
You can’t perform that action at this time.
0 commit comments