Struct ext_php_rs::describe::abi::Str
source · #[repr(C)]pub struct Str { /* private fields */ }
Expand description
An immutable, ABI-stable borrowed &'static str
.
Implementations§
source§impl Str
impl Str
sourcepub fn str(&self) -> &'static str
pub fn str(&self) -> &'static str
Returns the string as a string slice.
The lifetime is 'static
and can outlive the Str
object, as you can
only initialize a Str
through a static reference.
Examples found in repository?
More examples
src/describe/stub.rs (line 211)
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
fn fmt_stub(&self, buf: &mut String) -> FmtResult {
self.docs.fmt_stub(buf)?;
let (_, name) = split_namespace(self.name.as_ref());
write!(buf, "class {} ", name)?;
if let Option::Some(extends) = &self.extends {
write!(buf, "extends {} ", extends)?;
}
if !self.implements.is_empty() {
write!(
buf,
"implements {} ",
self.implements
.iter()
.map(|s| s.str())
.collect::<StdVec<_>>()
.join(", ")
)?;
}
writeln!(buf, "{{")?;
fn stub<T: ToStub>(items: &[T]) -> impl Iterator<Item = Result<String, FmtError>> + '_ {
items
.iter()
.map(|item| item.to_stub().map(|stub| indent(&stub, 4)))
}
buf.push_str(
&stub(&self.constants)
.chain(stub(&self.properties))
.chain(stub(&self.methods))
.collect::<Result<StdVec<_>, FmtError>>()?
.join(NEW_LINE_SEPARATOR),
);
writeln!(buf, "}}")
}