1*d14e28a8SLuo Jia / Zhouqi Jiang /// 向控制台打印字符串。 2*d14e28a8SLuo Jia / Zhouqi Jiang /// 3*d14e28a8SLuo Jia / Zhouqi Jiang /// 该函数接受一个字节切片 `s` 作为输入,并迭代切片中的每个字节 `c`。 4*d14e28a8SLuo Jia / Zhouqi Jiang /// 然后调用 `sbi_rt::console_write_byte` 函数,将 `c` 的值作为参数传递给它。 5*d14e28a8SLuo Jia / Zhouqi Jiang /// 6*d14e28a8SLuo Jia / Zhouqi Jiang /// # 安全性 7*d14e28a8SLuo Jia / Zhouqi Jiang /// 8*d14e28a8SLuo Jia / Zhouqi Jiang /// 这个函数是安全的,因为对SBI环境的操作不涉及不安全内存的访问操作。 9*d14e28a8SLuo Jia / Zhouqi Jiang /// 10*d14e28a8SLuo Jia / Zhouqi Jiang /// # 参数 11*d14e28a8SLuo Jia / Zhouqi Jiang /// 12*d14e28a8SLuo Jia / Zhouqi Jiang /// * `s` - 表示要打印的字符串的字节切片。 13*d14e28a8SLuo Jia / Zhouqi Jiang /// 14*d14e28a8SLuo Jia / Zhouqi Jiang /// # 示例 15*d14e28a8SLuo Jia / Zhouqi Jiang /// 16*d14e28a8SLuo Jia / Zhouqi Jiang /// ``` 17*d14e28a8SLuo Jia / Zhouqi Jiang /// let message = b"Hello, World!"; 18*d14e28a8SLuo Jia / Zhouqi Jiang /// console_putstr(message); 19*d14e28a8SLuo Jia / Zhouqi Jiang /// ``` 20*d14e28a8SLuo Jia / Zhouqi Jiang pub fn console_putstr(s: &[u8]) { 21*d14e28a8SLuo Jia / Zhouqi Jiang for c in s { 22*d14e28a8SLuo Jia / Zhouqi Jiang sbi_rt::console_write_byte(*c); 23*d14e28a8SLuo Jia / Zhouqi Jiang } 24*d14e28a8SLuo Jia / Zhouqi Jiang } 25