#Getting `&str` from `String` in const context
18 messages · Page 1 of 1 (latest)
uh how did you get a non-empty String in a const context?
/// A single stackframe
#[derive(Debug)]
pub struct Stackframe {
source_location: SourceLocation,
name: Option<String>
}
impl Stackframe {
/// Creates a new [`Stackframe`].
pub const fn new(source_location: SourceLocation, name: Option<String>) -> Self {
Self { source_location, name }
}
/// Fetches the source location of the stackframe.
pub const fn source_location(&self) -> &SourceLocation {
&self.source_location
}
/// Gets the name of the stackframe (which may not exist, for lambda functions).
pub const fn name(&self) -> Option<&str> {
// ???
}
}```
.as_str() and .as_ref() dont work and &*x doesnt work either
(not to mention .as_deref(), which would be nicer)
are you willing to use ultra unsafe features?
unstable or unsafe?
that's also an option
its not useful in a const context anyway