rust(44)-链表(1)

    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `F:\learn\rustlearn\learn45\target\debug\learn45.exe`
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[]
19
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
[198, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]


------------------
(program exited with code: 0)

请按任意键继续. . .
use std::collections::LinkedList;
fn main() {
	let mut lst1=LinkedList::new();
	for i in 1..10{
	    lst1.push_back(i);		
	}
	let mut lst2=LinkedList::new();
	for i in 10..20{
	    lst2.push_back(i);		
	}
    println!("{:?}",lst1); 
    println!("{:?}",lst2); 
    lst1.append(&mut lst2);
    println!("{:?}",lst1); 
    println!("{:?}",lst2); 
    lst1.pop_front();
    println!("{:?}",lst1.pop_back().unwrap());
    println!("{:?}",lst1);  
    lst1.push_front(198); 
    println!("{:?}",lst1); 

}
发布了448 篇原创文章 · 获赞 13 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/AI_LX/article/details/104967999
44