artichoke_core/
warn.rs

1//! Emit warnings during interpreter execution.
2
3/// Emit warnings during interpreter execution to stderr.
4///
5/// Some functionality required to be compliant with ruby/spec is deprecated or
6/// invalid behavior and ruby/spec expects a warning to be emitted to `$stderr`
7/// using the [`Warning`][warningmod] module from the standard library.
8///
9/// [warningmod]: https://ruby-doc.org/core-3.1.2/Warning.html#method-i-warn
10pub trait Warn {
11    /// Concrete error type for errors encountered when outputting warnings.
12    type Error;
13
14    /// Emit a warning message using `Warning#warn`.
15    ///
16    /// This method appends newlines to message if necessary.
17    ///
18    /// # Errors
19    ///
20    /// Interpreters should issue warnings by calling the `warn` method on the
21    /// `Warning` module.
22    ///
23    /// If an exception is raised on the interpreter, then an error is returned.
24    fn warn(&mut self, message: &[u8]) -> Result<(), Self::Error>;
25}