Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default "std" feature for windows-registry crate #3214

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ jobs:
run: cargo clippy -p test_readme
- name: Clippy test_registry
run: cargo clippy -p test_registry
- name: Clippy test_registry_default
run: cargo clippy -p test_registry_default
- name: Clippy test_reserved
run: cargo clippy -p test_reserved
- name: Clippy test_resources
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ jobs:
run: cargo test -p test_readme --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry
run: cargo test -p test_registry --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry_default
run: cargo test -p test_registry_default --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reserved
run: cargo test -p test_reserved --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_resources
Expand All @@ -253,10 +255,10 @@ jobs:
run: cargo test -p test_riddle --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_standalone
run: cargo test -p test_standalone --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_string_param
run: cargo test -p test_string_param --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test test_string_param
run: cargo test -p test_string_param --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_strings
run: cargo test -p test_strings --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_structs
Expand Down
4 changes: 4 additions & 0 deletions crates/libs/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ default-features = false
version = "0.1.0"
path = "../strings"
default-features = false

[features]
default = ["std"]
std = ["windows-result/std", "windows-strings/std"]
12 changes: 12 additions & 0 deletions crates/tests/registry_default/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "test_registry_default"
version = "0.0.0"
edition = "2021"
publish = false

[lib]
doc = false
doctest = false

[dependencies.windows-registry]
path = "../../libs/registry"
1 change: 1 addition & 0 deletions crates/tests/registry_default/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 21 additions & 0 deletions crates/tests/registry_default/tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This just confirms that the default feature "std" for the `windows-registry` crate also enables the
// default feature "std" for both the `windows-result` and `windows-strings` dependencies.
//
// `Box<dyn std::error::Error>` requires "std" feature for the `windows-result` crate.
#[test]
fn test() -> Result<(), Box<dyn std::error::Error>> {
let test_key = "software\\windows-rs\\tests\\default";
_ = windows_registry::CURRENT_USER.remove_tree(test_key);
let key = windows_registry::CURRENT_USER.create(test_key)?;

key.set_u32("u32", 123u32)?;
assert_eq!(key.get_u32("u32")?, 123u32);

// `to_os_string` requires the "std" feature for the `windows-strings` crate.
assert_eq!(
windows_registry::HSTRING::from("value").to_os_string(),
"value"
);

Ok(())
}