Holochain Forum

How to create a Rust method that doesn't have a return value?

Hi Gang,

This may be quite a simple one, but I am just getting back into Rust again and wanted to create a simple test method to call and test my new Signal code in the HoloNET .NET/Unity client I am currently upgrading to support Signals and other cool new features.

I have this in my zome:


        fn test_signals() -> ZomeApiResult<bool> {

            let message = "Hello World".to_string();

            hdk::emit_signal("message_received", SignalPayload{message});



But I am getting this error back from the Rust compiler:

error: unused `std::result::Result` that must be used
  --> src/lib.rs:64:9
64 |         hdk::emit_signal("message_received", SignalPayload{message});
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: `-D unused-must-use` implied by `-D warnings`
   = note: this `Result` may be an `Err` variant, which should be handled

error: aborting due to previous error

error: could not compile `our_world_core`.

Any help would be really appreciated.

Many thanks,

let _ = hdk::emit_signal("message_received", SignalPayload{message});

hdk::emit_signal("message_received", SignalPayload{message}).ok();

1 Like

Thank you, that worked! :slight_smile: