Skip to content

Commit

Permalink
code: Allow dead_code for methods only used in features
Browse files Browse the repository at this point in the history
  • Loading branch information
felinira committed Dec 9, 2023
1 parent 817e638 commit 7a233f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ pub enum Mood {
Unwelcome,
}

#[allow(dead_code)]
pub const APPID_RAW: &str = "lothar.com/wormhole/text-or-file-xfer";

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl VersionsMessage {
self.app_versions = versions;
}

#[cfg(feature = "dilation")]
pub fn enable_dilation(&mut self) {
self.can_dilate = Some([std::borrow::Cow::Borrowed("1")])
}
Expand Down Expand Up @@ -378,6 +379,7 @@ mod test {
// }

#[test]
#[cfg(dilation)]
fn test_versions_message_can_dilate() {
let mut message = VersionsMessage::new();

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#![forbid(unsafe_code)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::too_many_arguments)]
#![allow(unused_macros)]

#[macro_use]
mod util;
Expand Down
4 changes: 4 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,20 @@ pub fn hashcash(resource: String, bits: u32) -> String {
}
}
#[cfg(not(target_family = "wasm"))]
#[allow(dead_code)]
pub async fn sleep(duration: std::time::Duration) {
async_std::task::sleep(duration).await
}

#[cfg(target_family = "wasm")]
#[allow(dead_code)]
pub async fn sleep(duration: std::time::Duration) {
/* Skip error handling. Waiting is best effort anyways */
let _ = wasm_timer::Delay::new(duration).await;
}

#[cfg(not(target_family = "wasm"))]
#[allow(dead_code)]
pub async fn timeout<F, T>(
duration: std::time::Duration,
future: F,
Expand All @@ -198,6 +201,7 @@ where
}

#[cfg(target_family = "wasm")]
#[allow(dead_code)]
pub async fn timeout<F, T>(duration: std::time::Duration, future: F) -> Result<T, std::io::Error>
where
F: futures::Future<Output = T>,
Expand Down

0 comments on commit 7a233f7

Please sign in to comment.