Skip to content

Commit 814bdeb

Browse files
committed
Cleanup
1 parent 3e29243 commit 814bdeb

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ license = "MIT"
1111
repository = "https://github.com/Choochmeque/tauri-plugin-iap"
1212

1313
[features]
14-
unstable = []
14+
unstable = ["dep:swift-bridge", "dep:serde_json"]
1515

1616
[dependencies]
1717
tauri = { version = "2.7.0" }
1818
serde = "1.0"
1919
thiserror = "2"
2020

21-
[target.'cfg(all(target_os = "macos", feature = "unstable"))'.dependencies]
22-
swift-bridge = { version = "0.1", features = ["async"] }
23-
serde_json = "1.0"
21+
[target.'cfg(target_os = "macos")'.dependencies]
22+
swift-bridge = { version = "0.1", features = ["async"], optional = true}
23+
serde_json = { version = "1.0", optional = true }
2424

2525
[build-dependencies]
2626
tauri-plugin = { version = "2.3.0", features = ["build"] }
2727

28-
[target.'cfg(all(target_os = "macos", feature = "unstable"))'.build-dependencies]
28+
[target.'cfg(target_os = "macos")'.build-dependencies]
2929
swift-bridge-build = "0.1"

build.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "macos" {
2424
let bridges = vec!["src/macos.rs"];
2525
for path in &bridges {
26-
println!("cargo:rerun-if-changed={}", path);
26+
println!("cargo:rerun-if-changed={path}");
2727
}
2828

2929
swift_bridge_build::parse_bridges(bridges)
@@ -59,15 +59,14 @@ fn main() {
5959
"cargo:rustc-link-search={}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/",
6060
&xcode_path
6161
);
62-
println!("cargo:rustc-link-search={}", "/usr/lib/swift");
62+
println!("cargo:rustc-link-search=/usr/lib/swift");
6363

6464
let p = "/Library/Developer/CommandLineTools/usr/lib/swift-5.5/macosx";
6565
println!("cargo:rustc-link-search=native={p}");
6666
println!("cargo:rustc-link-arg=-Wl,-rpath,{p}");
6767

6868
println!(
69-
"cargo:rustc-link-search={}",
70-
"/Library/Developer/CommandLineTools/usr/lib/swift-5.5/macosx"
69+
"cargo:rustc-link-search=/Library/Developer/CommandLineTools/usr/lib/swift-5.5/macosx"
7170
);
7271
}
7372
}
@@ -79,7 +78,7 @@ fn compile_swift() {
7978

8079
let mut cmd = Command::new("swift");
8180

82-
cmd.current_dir(swift_package_dir).arg("build").args(&[
81+
cmd.current_dir(swift_package_dir).arg("build").args([
8382
"-Xswiftc",
8483
"-import-objc-header",
8584
"-Xswiftc",
@@ -90,7 +89,7 @@ fn compile_swift() {
9089
]);
9190

9291
if is_release_build() {
93-
cmd.args(&["-c", "release"]);
92+
cmd.args(["-c", "release"]);
9493
}
9594

9695
let exit_status = cmd.spawn().unwrap().wait_with_output().unwrap();
@@ -141,5 +140,5 @@ fn swift_library_static_lib_dir() -> PathBuf {
141140
"debug"
142141
};
143142

144-
manifest_dir().join(format!("macos/.build/{}", debug_or_release))
143+
manifest_dir().join(format!("macos/.build/{debug_or_release}"))
145144
}

src/macos.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ impl<R: Runtime> Iap<R> {
3939
fn to_result<T: serde::de::DeserializeOwned>(bridged: ffi::FFIResult) -> crate::Result<T> {
4040
match bridged {
4141
ffi::FFIResult::Ok(response) => {
42-
let parsed: T =
43-
serde_json::from_str(&response).map_err(Into::<serde_json::Error>::into)?;
42+
let parsed: T = serde_json::from_str(&response)?;
4443
Ok(parsed)
4544
}
4645
ffi::FFIResult::Err(err) => {
47-
Err(std::io::Error::new(std::io::ErrorKind::Other, err).into())
46+
Err(std::io::Error::other(err).into())
4847
}
4948
}
5049
}

0 commit comments

Comments
 (0)