pub struct Function {
pub name: String,
pub return_type: Option<String>,
pub arguments: Vec<Argument>,
pub description: Option<Description>,
}
Expand description
Represents a parsed function type.
Fields§
§name: String
§return_type: Option<String>
§arguments: Vec<Argument>
§description: Option<Description>
Implementations§
Source§impl Function
impl Function
Sourcepub fn new<S: Into<String>>(name: S) -> Self
pub fn new<S: Into<String>>(name: S) -> Self
Creates a new Function instance.
§Example
use thinlinelib::analysis::Function;
let function = Function::new("testFunction");
assert_eq!(function.name, String::from("testFunction"));
assert!(function.return_type.is_none());
assert!(function.arguments.is_empty());
assert!(function.description.is_none());
Sourcepub fn set_return_type(&mut self, ftype: &str) -> Fallible<()>
pub fn set_return_type(&mut self, ftype: &str) -> Fallible<()>
Creates the format type for the Function.
§Example
use thinlinelib::analysis::Function;
let mut function = Function::new("testFunction");
function.set_return_type("int");
assert_eq!(function.return_type, Some(String::from("int")));
function.set_return_type("");
assert_eq!(function.return_type, None);
Sourcepub fn set_description(&mut self, description: &str)
pub fn set_description(&mut self, description: &str)
Sets the description for the Function.
§Example
use thinlinelib::analysis::Function;
let mut function = Function::new("testFunction");
function.set_description("
int test_no = 2;
#EQ[TL_FCT(no1: test_no, no2: 5) => 7]
#EQ[TL_FCT(no1: 5, no2: 2) => 7]
EXPECT_EQ(11, test_int_no1(9, 2));
");
assert!(function.description.is_some());
Sourcepub fn set_arguments(&mut self, arguments: &[Argument])
pub fn set_arguments(&mut self, arguments: &[Argument])
Sets arguments for the Function.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Function
impl<'de> Deserialize<'de> for Function
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl EntityConversion for Function
impl EntityConversion for Function
impl StructuralPartialEq for Function
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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