diff --git a/codes/rust/chapter_array_and_linkedlist/array.rs b/codes/rust/chapter_array_and_linkedlist/array.rs index 5d779e40..2d6870b7 100644 --- a/codes/rust/chapter_array_and_linkedlist/array.rs +++ b/codes/rust/chapter_array_and_linkedlist/array.rs @@ -4,8 +4,7 @@ * Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::print_util; use rand::Rng; /* 随机访问元素 */ diff --git a/codes/rust/chapter_array_and_linkedlist/linked_list.rs b/codes/rust/chapter_array_and_linkedlist/linked_list.rs index 8f054f1c..601a9971 100644 --- a/codes/rust/chapter_array_and_linkedlist/linked_list.rs +++ b/codes/rust/chapter_array_and_linkedlist/linked_list.rs @@ -4,9 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - -use list_node::ListNode; +use hello_algo_rust::include::{print_util, ListNode}; use std::cell::RefCell; use std::rc::Rc; diff --git a/codes/rust/chapter_array_and_linkedlist/list.rs b/codes/rust/chapter_array_and_linkedlist/list.rs index b723489d..d2f267be 100644 --- a/codes/rust/chapter_array_and_linkedlist/list.rs +++ b/codes/rust/chapter_array_and_linkedlist/list.rs @@ -3,8 +3,7 @@ * Created Time: 2023-01-18 * Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com) */ - -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* Driver Code */ fn main() { diff --git a/codes/rust/chapter_array_and_linkedlist/my_list.rs b/codes/rust/chapter_array_and_linkedlist/my_list.rs index bc9375f3..8575cee5 100644 --- a/codes/rust/chapter_array_and_linkedlist/my_list.rs +++ b/codes/rust/chapter_array_and_linkedlist/my_list.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 列表类 */ #[allow(dead_code)] diff --git a/codes/rust/chapter_backtracking/preorder_traversal_i_compact.rs b/codes/rust/chapter_backtracking/preorder_traversal_i_compact.rs index 48966876..fc699395 100644 --- a/codes/rust/chapter_backtracking/preorder_traversal_i_compact.rs +++ b/codes/rust/chapter_backtracking/preorder_traversal_i_compact.rs @@ -4,10 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode}; use std::{cell::RefCell, rc::Rc}; -use tree_node::{vec_to_tree, TreeNode}; /* 前序遍历:例题一 */ fn pre_order(res: &mut Vec>>, root: Option<&Rc>>) { diff --git a/codes/rust/chapter_backtracking/preorder_traversal_ii_compact.rs b/codes/rust/chapter_backtracking/preorder_traversal_ii_compact.rs index 3fcda5c1..67ce5aee 100644 --- a/codes/rust/chapter_backtracking/preorder_traversal_ii_compact.rs +++ b/codes/rust/chapter_backtracking/preorder_traversal_ii_compact.rs @@ -4,10 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode}; use std::{cell::RefCell, rc::Rc}; -use tree_node::{vec_to_tree, TreeNode}; /* 前序遍历:例题二 */ fn pre_order( diff --git a/codes/rust/chapter_backtracking/preorder_traversal_iii_compact.rs b/codes/rust/chapter_backtracking/preorder_traversal_iii_compact.rs index db5a27e3..9e54e66b 100644 --- a/codes/rust/chapter_backtracking/preorder_traversal_iii_compact.rs +++ b/codes/rust/chapter_backtracking/preorder_traversal_iii_compact.rs @@ -4,10 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode}; use std::{cell::RefCell, rc::Rc}; -use tree_node::{vec_to_tree, TreeNode}; /* 前序遍历:例题三 */ fn pre_order( diff --git a/codes/rust/chapter_backtracking/preorder_traversal_iii_template.rs b/codes/rust/chapter_backtracking/preorder_traversal_iii_template.rs index 8be60523..e7681b11 100644 --- a/codes/rust/chapter_backtracking/preorder_traversal_iii_template.rs +++ b/codes/rust/chapter_backtracking/preorder_traversal_iii_template.rs @@ -4,10 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode}; use std::{cell::RefCell, rc::Rc}; -use tree_node::{vec_to_tree, TreeNode}; /* 判断当前状态是否为解 */ fn is_solution(state: &mut Vec>>) -> bool { diff --git a/codes/rust/chapter_computational_complexity/space_complexity.rs b/codes/rust/chapter_computational_complexity/space_complexity.rs index cd41b2b1..d1583fe2 100644 --- a/codes/rust/chapter_computational_complexity/space_complexity.rs +++ b/codes/rust/chapter_computational_complexity/space_complexity.rs @@ -4,13 +4,10 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - -use list_node::ListNode; +use hello_algo_rust::include::{print_util, ListNode, TreeNode}; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; -use tree_node::TreeNode; /* 函数 */ fn function() -> i32 { diff --git a/codes/rust/chapter_computational_complexity/worst_best_time_complexity.rs b/codes/rust/chapter_computational_complexity/worst_best_time_complexity.rs index 20d8ed33..df776625 100644 --- a/codes/rust/chapter_computational_complexity/worst_best_time_complexity.rs +++ b/codes/rust/chapter_computational_complexity/worst_best_time_complexity.rs @@ -4,8 +4,7 @@ * Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::print_util; use rand::seq::SliceRandom; use rand::thread_rng; diff --git a/codes/rust/chapter_divide_and_conquer/build_tree.rs b/codes/rust/chapter_divide_and_conquer/build_tree.rs index 2c1df9c6..e13ae641 100644 --- a/codes/rust/chapter_divide_and_conquer/build_tree.rs +++ b/codes/rust/chapter_divide_and_conquer/build_tree.rs @@ -4,10 +4,9 @@ * Author: codingonion (coderonion@gmail.com) */ +use hello_algo_rust::include::{print_util, TreeNode}; use std::collections::HashMap; use std::{cell::RefCell, rc::Rc}; -include!("../include/include.rs"); -use tree_node::TreeNode; /* 构建二叉树:分治 */ fn dfs( diff --git a/codes/rust/chapter_graph/graph_adjacency_list.rs b/codes/rust/chapter_graph/graph_adjacency_list.rs index 26b0692b..5e014d10 100644 --- a/codes/rust/chapter_graph/graph_adjacency_list.rs +++ b/codes/rust/chapter_graph/graph_adjacency_list.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/vertex.rs"); +pub use hello_algo_rust::include::{vals_to_vets, vets_to_vals, Vertex}; use std::collections::HashMap; diff --git a/codes/rust/chapter_hashing/build_in_hash.rs b/codes/rust/chapter_hashing/build_in_hash.rs index 7ea7620b..456f9791 100644 --- a/codes/rust/chapter_hashing/build_in_hash.rs +++ b/codes/rust/chapter_hashing/build_in_hash.rs @@ -4,9 +4,8 @@ * Author: WSL0809 (wslzzy@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::ListNode; -use crate::list_node::ListNode; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; diff --git a/codes/rust/chapter_hashing/hash_map.rs b/codes/rust/chapter_hashing/hash_map.rs index db5b76b5..53200d05 100644 --- a/codes/rust/chapter_hashing/hash_map.rs +++ b/codes/rust/chapter_hashing/hash_map.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::collections::HashMap; diff --git a/codes/rust/chapter_heap/heap.rs b/codes/rust/chapter_heap/heap.rs index 4c0d9d9d..ef4f3500 100644 --- a/codes/rust/chapter_heap/heap.rs +++ b/codes/rust/chapter_heap/heap.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::collections::BinaryHeap; diff --git a/codes/rust/chapter_heap/my_heap.rs b/codes/rust/chapter_heap/my_heap.rs index b087c194..18b67c62 100644 --- a/codes/rust/chapter_heap/my_heap.rs +++ b/codes/rust/chapter_heap/my_heap.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 大顶堆 */ struct MaxHeap { diff --git a/codes/rust/chapter_heap/top_k.rs b/codes/rust/chapter_heap/top_k.rs index fdfdb97c..d7907614 100644 --- a/codes/rust/chapter_heap/top_k.rs +++ b/codes/rust/chapter_heap/top_k.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::cmp::Reverse; use std::collections::BinaryHeap; diff --git a/codes/rust/chapter_searching/hashing_search.rs b/codes/rust/chapter_searching/hashing_search.rs index 1e41bc0b..b2229edc 100644 --- a/codes/rust/chapter_searching/hashing_search.rs +++ b/codes/rust/chapter_searching/hashing_search.rs @@ -4,9 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - -use list_node::ListNode; +use hello_algo_rust::include::ListNode; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; diff --git a/codes/rust/chapter_searching/linear_search.rs b/codes/rust/chapter_searching/linear_search.rs index 5a0d131d..25f6547b 100644 --- a/codes/rust/chapter_searching/linear_search.rs +++ b/codes/rust/chapter_searching/linear_search.rs @@ -4,9 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - -use list_node::ListNode; +use hello_algo_rust::include::ListNode; use std::cell::RefCell; use std::rc::Rc; diff --git a/codes/rust/chapter_searching/two_sum.rs b/codes/rust/chapter_searching/two_sum.rs index 6766db5d..5f38d372 100644 --- a/codes/rust/chapter_searching/two_sum.rs +++ b/codes/rust/chapter_searching/two_sum.rs @@ -4,8 +4,7 @@ * Author: xBLACICEx (xBLACKICEx@outlook.com), codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::print_util; use std::collections::HashMap; /* 方法一:暴力枚举 */ diff --git a/codes/rust/chapter_sorting/bubble_sort.rs b/codes/rust/chapter_sorting/bubble_sort.rs index 2557a222..972eb690 100644 --- a/codes/rust/chapter_sorting/bubble_sort.rs +++ b/codes/rust/chapter_sorting/bubble_sort.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 冒泡排序 */ fn bubble_sort(nums: &mut [i32]) { diff --git a/codes/rust/chapter_sorting/bucket_sort.rs b/codes/rust/chapter_sorting/bucket_sort.rs index 02e09abf..c959559a 100644 --- a/codes/rust/chapter_sorting/bucket_sort.rs +++ b/codes/rust/chapter_sorting/bucket_sort.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 桶排序 */ fn bucket_sort(nums: &mut [f64]) { diff --git a/codes/rust/chapter_sorting/counting_sort.rs b/codes/rust/chapter_sorting/counting_sort.rs index c6a5d92c..ed478afb 100644 --- a/codes/rust/chapter_sorting/counting_sort.rs +++ b/codes/rust/chapter_sorting/counting_sort.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 计数排序 */ // 简单实现,无法用于排序对象 diff --git a/codes/rust/chapter_sorting/heap_sort.rs b/codes/rust/chapter_sorting/heap_sort.rs index 55ab5242..a70c2c8a 100644 --- a/codes/rust/chapter_sorting/heap_sort.rs +++ b/codes/rust/chapter_sorting/heap_sort.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 堆的长度为 n ,从节点 i 开始,从顶至底堆化 */ fn sift_down(nums: &mut [i32], n: usize, mut i: usize) { diff --git a/codes/rust/chapter_sorting/insertion_sort.rs b/codes/rust/chapter_sorting/insertion_sort.rs index 37b685aa..8772e7d0 100644 --- a/codes/rust/chapter_sorting/insertion_sort.rs +++ b/codes/rust/chapter_sorting/insertion_sort.rs @@ -4,7 +4,7 @@ * Author: xBLACKICEx (xBLACKICEx@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 插入排序 */ fn insertion_sort(nums: &mut [i32]) { diff --git a/codes/rust/chapter_sorting/radix_sort.rs b/codes/rust/chapter_sorting/radix_sort.rs index 722826e1..f213c427 100644 --- a/codes/rust/chapter_sorting/radix_sort.rs +++ b/codes/rust/chapter_sorting/radix_sort.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */ fn digit(num: i32, exp: i32) -> usize { diff --git a/codes/rust/chapter_sorting/selection_sort.rs b/codes/rust/chapter_sorting/selection_sort.rs index 9b21d9bc..87265a54 100644 --- a/codes/rust/chapter_sorting/selection_sort.rs +++ b/codes/rust/chapter_sorting/selection_sort.rs @@ -4,7 +4,7 @@ * Author: WSL0809 (wslzzy@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 选择排序 */ fn selection_sort(nums: &mut [i32]) { diff --git a/codes/rust/chapter_stack_and_queue/array_deque.rs b/codes/rust/chapter_stack_and_queue/array_deque.rs index 8ad4e487..905c371f 100644 --- a/codes/rust/chapter_stack_and_queue/array_deque.rs +++ b/codes/rust/chapter_stack_and_queue/array_deque.rs @@ -3,9 +3,7 @@ * Created Time: 2023-03-11 * Author: codingonion (coderonion@gmail.com) */ - -include!("../include/include.rs"); - +use hello_algo_rust::include::print_util; /* 基于环形数组实现的双向队列 */ struct ArrayDeque { nums: Vec, // 用于存储双向队列元素的数组 diff --git a/codes/rust/chapter_stack_and_queue/array_stack.rs b/codes/rust/chapter_stack_and_queue/array_stack.rs index 4aab6dc2..19c90220 100644 --- a/codes/rust/chapter_stack_and_queue/array_stack.rs +++ b/codes/rust/chapter_stack_and_queue/array_stack.rs @@ -4,7 +4,7 @@ * Author: WSL0809 (wslzzy@outlook.com), codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* 基于数组实现的栈 */ struct ArrayStack { diff --git a/codes/rust/chapter_stack_and_queue/deque.rs b/codes/rust/chapter_stack_and_queue/deque.rs index 48697503..28b3ad38 100644 --- a/codes/rust/chapter_stack_and_queue/deque.rs +++ b/codes/rust/chapter_stack_and_queue/deque.rs @@ -4,8 +4,7 @@ * Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com) */ -include!("../include/include.rs"); - +use hello_algo_rust::include::print_util; use std::collections::VecDeque; /* Driver Code */ diff --git a/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs b/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs index b181f8ff..dda3adb6 100644 --- a/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs +++ b/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::cell::RefCell; use std::rc::Rc; diff --git a/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs b/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs index 1b940a03..ee2f68f3 100644 --- a/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs +++ b/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs @@ -4,9 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{print_util, ListNode}; -use list_node::ListNode; use std::cell::RefCell; use std::rc::Rc; diff --git a/codes/rust/chapter_stack_and_queue/linkedlist_stack.rs b/codes/rust/chapter_stack_and_queue/linkedlist_stack.rs index f2d479ae..0a96df0e 100644 --- a/codes/rust/chapter_stack_and_queue/linkedlist_stack.rs +++ b/codes/rust/chapter_stack_and_queue/linkedlist_stack.rs @@ -4,9 +4,8 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{print_util, ListNode}; -use list_node::ListNode; use std::cell::RefCell; use std::rc::Rc; diff --git a/codes/rust/chapter_stack_and_queue/queue.rs b/codes/rust/chapter_stack_and_queue/queue.rs index 56144666..e2fd8400 100644 --- a/codes/rust/chapter_stack_and_queue/queue.rs +++ b/codes/rust/chapter_stack_and_queue/queue.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::collections::VecDeque; diff --git a/codes/rust/chapter_stack_and_queue/stack.rs b/codes/rust/chapter_stack_and_queue/stack.rs index 64e21424..b2df65b5 100644 --- a/codes/rust/chapter_stack_and_queue/stack.rs +++ b/codes/rust/chapter_stack_and_queue/stack.rs @@ -4,7 +4,7 @@ * Author: codingonion (coderonion@gmail.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; /* Driver Code */ pub fn main() { diff --git a/codes/rust/chapter_tree/array_binary_tree.rs b/codes/rust/chapter_tree/array_binary_tree.rs index 1ce7e904..98504159 100644 --- a/codes/rust/chapter_tree/array_binary_tree.rs +++ b/codes/rust/chapter_tree/array_binary_tree.rs @@ -4,7 +4,7 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{print_util, tree_node}; /* 数组表示下的二叉树类 */ struct ArrayBinaryTree { diff --git a/codes/rust/chapter_tree/avl_tree.rs b/codes/rust/chapter_tree/avl_tree.rs index a48ec813..faa3787e 100644 --- a/codes/rust/chapter_tree/avl_tree.rs +++ b/codes/rust/chapter_tree/avl_tree.rs @@ -4,12 +4,11 @@ * Author: night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{print_util, TreeNode}; use std::cell::RefCell; use std::cmp::Ordering; use std::rc::Rc; -use tree_node::TreeNode; type OptionTreeNodeRc = Option>>; diff --git a/codes/rust/chapter_tree/binary_search_tree.rs b/codes/rust/chapter_tree/binary_search_tree.rs index aca3f433..21daad9f 100644 --- a/codes/rust/chapter_tree/binary_search_tree.rs +++ b/codes/rust/chapter_tree/binary_search_tree.rs @@ -4,13 +4,13 @@ * Author: xBLACKICEx (xBLACKICE@outlook.com)、night-cruise (2586447362@qq.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::print_util; use std::cell::RefCell; use std::cmp::Ordering; use std::rc::Rc; -use tree_node::TreeNode; +use hello_algo_rust::include::TreeNode; type OptionTreeNodeRc = Option>>; diff --git a/codes/rust/chapter_tree/binary_tree.rs b/codes/rust/chapter_tree/binary_tree.rs index 82308861..5843845d 100644 --- a/codes/rust/chapter_tree/binary_tree.rs +++ b/codes/rust/chapter_tree/binary_tree.rs @@ -4,8 +4,7 @@ * Author: xBLACKICEx (xBLACKICE@outlook.com) */ use std::rc::Rc; -include!("../include/include.rs"); -use tree_node::TreeNode; +use hello_algo_rust::include::{print_util, TreeNode}; /* Driver Code */ fn main() { diff --git a/codes/rust/chapter_tree/binary_tree_bfs.rs b/codes/rust/chapter_tree/binary_tree_bfs.rs index 572f8835..e50c2df9 100644 --- a/codes/rust/chapter_tree/binary_tree_bfs.rs +++ b/codes/rust/chapter_tree/binary_tree_bfs.rs @@ -4,11 +4,11 @@ * Author: xBLACKICEx (xBLACKICE@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{print_util, vec_to_tree, TreeNode}; +use hello_algo_rust::op_vec; use std::collections::VecDeque; use std::{cell::RefCell, rc::Rc}; -use tree_node::{vec_to_tree, TreeNode}; /* 层序遍历 */ fn level_order(root: &Rc>) -> Vec { diff --git a/codes/rust/chapter_tree/binary_tree_dfs.rs b/codes/rust/chapter_tree/binary_tree_dfs.rs index 22f978ff..56c68614 100644 --- a/codes/rust/chapter_tree/binary_tree_dfs.rs +++ b/codes/rust/chapter_tree/binary_tree_dfs.rs @@ -4,11 +4,11 @@ * Author: xBLACKICEx (xBLACKICE@outlook.com) */ -include!("../include/include.rs"); +use hello_algo_rust::include::{vec_to_tree, TreeNode, print_util}; +use hello_algo_rust::op_vec; use std::cell::RefCell; use std::rc::Rc; -use tree_node::{vec_to_tree, TreeNode}; /* 前序遍历 */ fn pre_order(root: Option<&Rc>>) -> Vec { diff --git a/codes/rust/include/list_node.rs b/codes/rust/src/include/list_node.rs similarity index 100% rename from codes/rust/include/list_node.rs rename to codes/rust/src/include/list_node.rs diff --git a/codes/rust/include/include.rs b/codes/rust/src/include/mod.rs similarity index 61% rename from codes/rust/include/include.rs rename to codes/rust/src/include/mod.rs index a288d8b5..6cba6f9a 100644 --- a/codes/rust/include/include.rs +++ b/codes/rust/src/include/mod.rs @@ -4,7 +4,13 @@ * Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICE@outlook.com) */ -pub mod print_util; pub mod list_node; +pub mod print_util; pub mod tree_node; -pub mod vertex; \ No newline at end of file +pub mod vertex; + +// rexport to include +pub use list_node::*; +pub use print_util::*; +pub use tree_node::*; +pub use vertex::*; diff --git a/codes/rust/include/print_util.rs b/codes/rust/src/include/print_util.rs similarity index 96% rename from codes/rust/include/print_util.rs rename to codes/rust/src/include/print_util.rs index 68b4870a..eccc659d 100644 --- a/codes/rust/include/print_util.rs +++ b/codes/rust/src/include/print_util.rs @@ -9,8 +9,8 @@ use std::fmt::Display; use std::collections::{HashMap, VecDeque}; use std::rc::Rc; -use crate::list_node::ListNode; -use crate::tree_node::{TreeNode, vec_to_tree}; +use super::list_node::ListNode; +use super::tree_node::{TreeNode, vec_to_tree}; struct Trunk<'a, 'b> { prev: Option<&'a Trunk<'a, 'b>>, @@ -99,5 +99,5 @@ pub fn print_heap(heap: Vec) { println!("堆的树状表示:"); if let Some(root) = vec_to_tree(heap.into_iter().map(|val| Some(val)).collect()) { print_tree(&root); - } -} \ No newline at end of file + } +} diff --git a/codes/rust/include/tree_node.rs b/codes/rust/src/include/tree_node.rs similarity index 100% rename from codes/rust/include/tree_node.rs rename to codes/rust/src/include/tree_node.rs diff --git a/codes/rust/include/vertex.rs b/codes/rust/src/include/vertex.rs similarity index 100% rename from codes/rust/include/vertex.rs rename to codes/rust/src/include/vertex.rs diff --git a/codes/rust/src/lib.rs b/codes/rust/src/lib.rs new file mode 100644 index 00000000..2883b910 --- /dev/null +++ b/codes/rust/src/lib.rs @@ -0,0 +1 @@ +pub mod include;