Correct `rapid-gossip-sync` `no-std` build and test
[rust-lightning] / lightning-rapid-gossip-sync / src / lib.rs
index eb6e285712ac2199ce6063edb0d96a7f1659e368..b3d1f0133dd37822c50ee722e6701cad74df0738 100644 (file)
 //! ```
 //! [sync_network_graph_with_file_path]: RapidGossipSync::sync_network_graph_with_file_path
 
+#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
+
 // Allow and import test features for benching
 #![cfg_attr(all(test, feature = "_bench_unstable"), feature(test))]
 #[cfg(all(test, feature = "_bench_unstable"))]
 extern crate test;
 
+#[cfg(not(feature = "std"))]
+extern crate alloc;
+
 #[cfg(feature = "std")]
 use std::fs::File;
 use core::ops::Deref;
@@ -143,6 +148,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
        }
 }
 
+#[cfg(feature = "std")]
 #[cfg(test)]
 mod tests {
        use std::fs;