mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 06:07:20 +08:00 
			
		
		
		
	* feat: add rust codes for linked_list * feat: add rust codes for my_list * Update linked_list.rs * Update print_util.rs --------- Co-authored-by: Yudong Jin <krahets@163.com>
		
			
				
	
	
		
			23 lines
		
	
	
		
			405 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			405 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
/*
 | 
						|
 * File: list_node.rs
 | 
						|
 * Created Time: 2023-03-05
 | 
						|
 * Author: sjinzh (sjinzh@gmail.com)
 | 
						|
 */
 | 
						|
 | 
						|
use std::rc::Rc;
 | 
						|
use std::cell::RefCell;
 | 
						|
 | 
						|
pub struct ListNode<T> {
 | 
						|
    pub val: T,
 | 
						|
    pub next: Option<Rc<RefCell<ListNode<T>>>>,
 | 
						|
}
 | 
						|
 | 
						|
impl<T> ListNode<T> {
 | 
						|
    pub fn new(val: T) -> Rc<RefCell<ListNode<T>>> {
 | 
						|
        Rc::new(RefCell::new(ListNode {
 | 
						|
            val,
 | 
						|
            next: None,
 | 
						|
        }))
 | 
						|
    }
 | 
						|
}
 |