mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
cargo fmt rust code (#1131)
* cargo fmt code * Add empty line to seperate unrelated comments * Fix review * Update bubble_sort.rs * Update merge_sort.rs --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@ -14,7 +14,9 @@ struct ArrayStack<T> {
|
||||
impl<T> ArrayStack<T> {
|
||||
/* 初始化栈 */
|
||||
fn new() -> ArrayStack<T> {
|
||||
ArrayStack::<T> { stack: Vec::<T>::new() }
|
||||
ArrayStack::<T> {
|
||||
stack: Vec::<T>::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/* 获取栈的长度 */
|
||||
@ -42,7 +44,9 @@ impl<T> ArrayStack<T> {
|
||||
|
||||
/* 访问栈顶元素 */
|
||||
fn peek(&self) -> Option<&T> {
|
||||
if self.is_empty() { panic!("栈为空") };
|
||||
if self.is_empty() {
|
||||
panic!("栈为空")
|
||||
};
|
||||
self.stack.last()
|
||||
}
|
||||
|
||||
@ -82,4 +86,4 @@ fn main() {
|
||||
// 判断是否为空
|
||||
let is_empty = stack.is_empty();
|
||||
print!("\n栈是否为空 = {is_empty}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user