Skip to content

Commit

Permalink
feat: compile with stable rust
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Jun 30, 2022
1 parent 5b80c8d commit 11631bf
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# 更新日志 Change Log

## v0.1.3

- 功能
- 移除不稳定特性,支持 stable 编译

---

- feature
- removes unstable features and allows to compile with stable rust

## v0.1.2

- 功能
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dtb-walker"
description = "A simple package for DTB depth-first walking."
version = "0.1.2"
version = "0.1.3"
edition = "2021"
authors = ["YdrMaster <[email protected]>"]
repository = "https://github.com/YdrMaster/dtb-walker.git"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ cargo run --release --example qemu-virt

特性:

- [x] 可选是否检查首部正确性;
- [x] stable rust
- [x] `no_std`
- [x] 不需要 `alloc`
- [x] 可选是否检查首部正确性;
- [x] 提前终止遍历;
- [x] 低开销跳过节点;
- [ ] 内置标准属性解析;
Expand Down
3 changes: 2 additions & 1 deletion docs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Following the [devicetree-specification-v0.4-rc1](https://github.com/devicetree-

Features:

- [x] optional header verifying;
- [x] stable rust
- [x] `no_std`;
- [x] without `alloc`;
- [x] optional header verifying;
- [x] terminate walking at any time;
- [x] step over nodes with low overhead;
- [ ] built-in standard property parsing;
Expand Down
2 changes: 0 additions & 2 deletions rust-toolchain.toml

This file was deleted.

6 changes: 5 additions & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,9 @@ fn misaligned(addr: u32) -> u32 {

#[inline]
fn check(filter: impl Fn(&HeaderError) -> bool, err: HeaderError) -> Result<(), HeaderError> {
filter(&err).then_some(()).ok_or(err)
if filter(&err) {
Ok(())
} else {
Err(err)
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(slice_internals)]
#![deny(warnings)] // cancel this line during developing

mod header;
Expand Down
2 changes: 1 addition & 1 deletion src/property/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> Iterator for StrList<'a> {
}
let (head, tail) = self
.0
.split_at(slice::memchr::memchr(b'\0', self.0).unwrap());
.split_at(self.0.iter().position(|c| *c == b'\0').unwrap());
self.0 = &tail[1..];
Some(Str(head))
}
Expand Down
2 changes: 1 addition & 1 deletion src/walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl Walker<'_> {
fn prop_name(&self, nameoff: Blk) -> &[u8] {
let nameoff = nameoff.into_u32() as usize;
let name = &self.strings[nameoff..];
&name[..slice::memchr::memchr(b'\0', name).unwrap()]
&name[..name.iter().position(|c| *c == b'\0').unwrap()]
}

/// 深度优先遍历。如果返回 `false`,取消所有后续的遍历。
Expand Down

0 comments on commit 11631bf

Please sign in to comment.