Ic_cdk::print deprecation for ic0::debug_print

Is there any particular reason why ic_cdk::print was deprecated in favor of ic0::debug_print? And if not, could this decision be revisited?

In my codebase, for example, I don’t have any direct dependencies on ic0. None of my Cargo.toml files list ic0 as a direct dependency. I develop most ic related features using the ic_cdk without explicitly adding the underlying ic0 crate, because well, I use the ic_cdk. I imagine it’s the common case for most Rust developers.

Now, if I want to print debug information using this new function ic0::debug_print but, I cannot do so without explicitly adding the crate to my project, because ic0 is otherwise unknown - or at least neither RustRover not cargo build manage to find it.

So, unless I’m missing something, either I have to add it temporarily just for debugging purposes (and then remove it) - which is a bit annoying - or I add ic0 as a permanent dependency - which is also a bit annoying.

Therefore, from that point of view, and again unless I’m missing something, I feel like it would be beneficial from a DX perspective to keep those debug functions available in ic_cdk and why I’m asking if there is a reason and if it can be revisited.

WDYT?

It is not being deprecated in favor of ic0::debug_print. It is deprecated in favor of ic_cdk::api::debug_print. debug_print in ic_cdk::api - Rust

1 Like

Good to know and great :+1:

Note that neither the deprecation message nor, the implementation mention the new package ic_cdk::api that’s why, I assumed it was moved in the other crate.

Reference from v0.18.5:

/// Prints the given message.
#[deprecated(since = "0.18.0", note = "Use `debug_print` instead")]
pub fn print<S: std::convert::AsRef<str>>(s: S) {
    let s = s.as_ref();
    ic0::debug_print(s.as_bytes());
}