Struct kotlin_poet_rs::spec::Annotation
source · pub struct Annotation { /* private fields */ }
Expand description
Represents an annotation in Kotlin. Used for adding meta information for code entities.
Official documentation reference
§Examples
use std::str::FromStr;
use kotlin_poet_rs::io::RenderKotlin;
use kotlin_poet_rs::spec::{Annotation, Argument, ClassLikeTypeName, CodeBlock, Name, Package};
let annotation = Annotation::new(
ClassLikeTypeName::top_level(
Package::from_str("a.b.c").unwrap(),
Name::from("MyAnnotation")
)
).argument(
Argument::new_named("value", CodeBlock::atom("1"))
).argument(
Argument::new_named("name", CodeBlock::atom("\"name_value\""))
);
assert_eq!(
annotation.render_string(),
"@a.b.c.MyAnnotation(value = 1, name = \"name_value\")"
);
Implementations§
source§impl Annotation
impl Annotation
pub fn new<ClassLikeTypeNameLike: Into<ClassLikeTypeName>>( type_name: ClassLikeTypeNameLike, ) -> Self
pub fn argument(self, argument: Argument) -> Self
pub fn target(self, target: AnnotationTarget) -> Self
Trait Implementations§
source§impl Clone for Annotation
impl Clone for Annotation
source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Annotation
impl Debug for Annotation
source§impl RenderKotlin for Annotation
impl RenderKotlin for Annotation
source§fn render_string(&self) -> String
fn render_string(&self) -> String
Shortcut method for converting RenderKotlin::render_into output into String.
Auto Trait Implementations§
impl Freeze for Annotation
impl RefUnwindSafe for Annotation
impl Send for Annotation
impl Sync for Annotation
impl Unpin for Annotation
impl UnwindSafe for Annotation
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)