Struct jbcrs::TypeDescriptor
[−]
[src]
pub struct TypeDescriptor { pub dimensions: u8, pub base_type: Type, }
A TypeDescriptor
is either a field descriptor,
a single type (parameter or return type) of a method,
or an element value of an annotation.
In the JVM Specification FieldDescriptor
is used as a name.
Maybe using that one would be better, but I am too lazy to refactor now.
Fields
dimensions: u8
The dimensions of the type
Examples
use jbcrs::TypeDescriptor; let desc: TypeDescriptor = "[[I".parse().unwrap(); assert_eq!(desc.dimensions, 2);
base_type: Type
The base type
Examples
use jbcrs::{Type, TypeDescriptor}; let short_desc: TypeDescriptor = "S".parse().unwrap(); assert_eq!(short_desc.base_type, Type::Short); let string_desc: TypeDescriptor = "[Ljava/lang/String;".parse().unwrap(); assert_eq!( string_desc.base_type, Type::Reference("java/lang/String".to_owned()) );
Methods
impl TypeDescriptor
[src]
fn new(dimensions: u8, base_type: Type) -> TypeDescriptor
[src]
Trait Implementations
impl Eq for TypeDescriptor
[src]
impl PartialEq for TypeDescriptor
[src]
fn eq(&self, __arg_0: &TypeDescriptor) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &TypeDescriptor) -> bool
[src]
This method tests for !=
.
impl Debug for TypeDescriptor
[src]
impl FromStr for TypeDescriptor
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(desc: &str) -> Result<TypeDescriptor>
[src]
Parses a string and returns a TypeDescriptor if it succeeded.
Examples
use jbcrs::{Type, TypeDescriptor}; let desc: TypeDescriptor = "[[[D".parse().unwrap(); assert_eq!(desc, TypeDescriptor { dimensions: 3, base_type: Type::Double });
impl Display for TypeDescriptor
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats this descriptor
Examples
use jbcrs::{Type, TypeDescriptor}; let mut desc: TypeDescriptor = "[[Ljava/lang/String;".parse().unwrap(); desc.base_type = Type::Float; assert_eq!("[[F", desc.to_string()); desc.base_type = Type::Reference("java/lang/Float".to_owned()); assert_eq!("[[Ljava/lang/Float;", desc.to_string());