pub struct Function {
pub name: String,
pub body: Rc<FullCompoundCommand>,
pub origin: Location,
pub read_only_location: Option<Location>,
}Expand description
Definition of a function.
Fields§
§name: StringString that identifies the function.
body: Rc<FullCompoundCommand>Command that is executed when the function is called.
This is wrapped in Rc so that we don’t have to clone the entire
compound command when we define a function. The function definition
command only clones the Rc object from the abstract syntax tree.
origin: LocationLocation of the function definition command that defined this function.
read_only_location: Option<Location>Optional location where this function was made read-only.
If this function is not read-only, read_only_location is None.
Otherwise, read_only_location is the location of the simple command
that executed the readonly built-in that made this function read-only.
Implementations§
Source§impl Function
impl Function
Sourcepub fn new<N: Into<String>, C: Into<Rc<FullCompoundCommand>>>(
name: N,
body: C,
origin: Location,
) -> Self
pub fn new<N: Into<String>, C: Into<Rc<FullCompoundCommand>>>( name: N, body: C, origin: Location, ) -> Self
Creates a new function.
This is a convenience function for constructing a Function object.
The read_only_location is set to None.
Sourcepub fn make_read_only(self, location: Location) -> Self
pub fn make_read_only(self, location: Location) -> Self
Makes the function read-only.
This is a convenience function for doing
self.read_only_location = Some(location) in a method chain.
Sourcepub const fn is_read_only(&self) -> bool
pub const fn is_read_only(&self) -> bool
Whether this function is read-only or not.
Trait Implementations§
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more