Skip to content

Commit 7d9ac3e

Browse files
committed
test4:complete support-hashmap try1
1 parent ef708dc commit 7d9ac3e

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

arceos/ulib/axstd/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ arceos_api = { workspace = true }
8080
axio = "0.1"
8181
axerrno = "0.1"
8282
kspin = "0.1"
83+
# 添加 hashbrown 依赖
84+
hashbrown = "0.16" # 或者使用项目中已有的版本 "0.16"

arceos/ulib/axstd/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@
5252

5353
#[cfg(feature = "alloc")]
5454
extern crate alloc;
55-
55+
// 确保 hashbrown 可用
56+
#[cfg(feature = "alloc")]
57+
extern crate hashbrown;
5658
#[cfg(feature = "alloc")]
5759
#[doc(no_inline)]
58-
pub use alloc::{boxed, collections, format, string, vec};
59-
60+
// pub use alloc::{boxed, collections, format, string, vec};
61+
pub use alloc::{boxed,format, string, vec};
62+
pub mod collections{
63+
// 使用 hashbrown 的 HashMap
64+
pub use hashbrown::HashMap;
65+
pub use alloc::vec::Vec;
66+
pub use alloc::string::String;
67+
}
6068
#[doc(no_inline)]
6169
pub use core::{arch, cell, cmp, hint, marker, mem, ops, ptr, slice, str};
6270

scripts/test-support_hashmap.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ make disk_img
1515

1616
make run A=exercises/support_hashmap/ | tee $tmp_file
1717

18-
output=$(tail -n1 ./$tmp_file | grep -a "$grep_content")
18+
# output=$(tail -n1 ./$tmp_file | grep -a "$grep_content")
19+
# 修改:检查整个文件而不是最后一行
20+
output=$(grep -a "$grep_content" ./$tmp_file)
1921

2022
rm -rf $tmp_file
2123

0 commit comments

Comments
 (0)