### Example Searches Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search= Provides examples of search queries that can be used within the project's search functionality. ```APIDOC ## Example Searches ### Description These are example search queries demonstrating how to find specific items or patterns within the project's codebase or documentation. ### Method N/A (Search Functionality) ### Endpoint N/A (Search Functionality) ### Parameters N/A (Search Functionality) ### Request Body N/A (Search Functionality) ### Response N/A (Search Functionality) ### Response Example ``` Example searches: * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` ``` -------------------------------- ### Trim Prefix Example in Rust Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the usage of `trim_prefix` to remove a specified prefix from a string slice. It shows cases where the prefix is present and absent, and includes an example of method chaining. ```rust #![feature(trim_prefix_suffix)] // Prefix present - removes it assert_eq!("foo:bar".trim_prefix("foo:"), "bar"); assert_eq!("foofoo".trim_prefix("foo"), "foo"); // Prefix absent - returns original string assert_eq!("foo:bar".trim_prefix("bar"), "foo:bar"); // Method chaining example assert_eq!("".trim_prefix('<').trim_suffix('>'), "https://example.com/"); ``` -------------------------------- ### Trim Suffix Example in Rust Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates the `trim_suffix` method for removing a specified suffix from a string slice. Examples cover cases with and without the suffix, and a demonstration of chaining with `trim_prefix`. ```rust #![feature(trim_prefix_suffix)] // Suffix present - removes it assert_eq!("bar:foo".trim_suffix(":foo"), "bar"); assert_eq!("foofoo".trim_suffix("foo"), "foo"); // Suffix absent - returns original string assert_eq!("bar:foo".trim_suffix("bar"), "bar:foo"); // Method chaining example assert_eq!("".trim_prefix('<').trim_suffix('>'), "https://example.com/"); ``` -------------------------------- ### Get String Length in Rust (Bytes) Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to get the length of a string in bytes using the `len()` method. It highlights that this length is in bytes, not characters, and provides examples with ASCII and multi-byte characters. ```rust let len = "foo".len(); assert_eq!(3, len); assert_eq!("ƒoo".len(), 4); // fancy f! assert_eq!("ƒoo".chars().count(), 3); ``` -------------------------------- ### Get Token Start Position Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/struct.TokenReference_search=std%3A%3Avec Returns the starting position of the token within the source code. This method is part of the `Deref` implementation, allowing `TokenReference` to be treated like a `Token` for position-related queries. ```rust pub fn start_position(&self) -> Position ``` -------------------------------- ### CloneToUninit Trait Implementation Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.GenericFor_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the nightly-only experimental `CloneToUninit` trait and its `clone_to_uninit` method. ```APIDOC ### impl CloneToUninit for T #### unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `clone_to_uninit` ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Label Constructors and Methods Source: https://docs.rs/full_moon/latest/full_moon/ast/lua52/struct.Label_search=std%3A%3Avec Details on how to create and manipulate Label instances. ```APIDOC ## impl Label ### `pub fn new(name: TokenReference) -> Self` Creates a new Label with the given name. ### `pub fn left_colons(&self) -> &TokenReference` The `::` symbol on the left hand side of the name. ### `pub fn name(&self) -> &TokenReference` The name used for the label, the `label` part of `::label::`. ### `pub fn right_colons(&self) -> &TokenReference` The `::` symbol on the right hand side of the name. ### `pub fn with_left_colons(self, left_colons: TokenReference) -> Self` Returns a new Label with the given `::` symbol on the left hand side. ### `pub fn with_name(self, name: TokenReference) -> Self` Returns a new Label with the given label name. ### `pub fn with_right_colons(self, right_colons: TokenReference) -> Self` Returns a new Label with the given `::` symbol on the right hand side. ``` -------------------------------- ### Get Attribute Start Position in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/lua54/struct.Attribute_search=u32+-%3E+bool Part of the Node trait implementation, this method returns the starting position of the Attribute node in the source code. It returns an Option which is None if the position cannot be determined. ```rust fn start_position(&self) -> Option ``` -------------------------------- ### Generic Blanket Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=u32+-%3E+bool Showcases blanket implementations that apply to various types, including BinOp, demonstrating common functionalities. ```APIDOC ## Blanket Implementations ### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. Read more ### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. Read more ### impl CloneToUninit for T where T: Clone, #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. Read more ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T where U: From, #### fn into(self) -> U Calls `U::from(self)`. ### impl ToOwned for T where T: Clone, #### type Owned = T The resulting type after obtaining ownership. #### fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. Read more #### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. Read more ### impl ToSmolStr for T where T: Display + ?Sized, #### fn to_smolstr(&self) -> SmolStr ### impl ToString for T where T: Display + ?Sized, #### fn to_string(&self) -> String Converts the given value to a `String`. Read more ### impl TryFrom for T where U: Into, #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T where U: TryFrom, #### type Error = >::Error The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> Performs the conversion. ### impl DeserializeOwned for T where T: for<'de> Deserialize<'de>, ``` -------------------------------- ### Get Type to Cast To (Rust) Source: https://docs.rs/full_moon/latest/full_moon/ast/luau/struct.TypeAssertion_search= Retrieves the `TypeInfo` that the expression is being cast to, for example, `number` in `:: number`. ```rust pub fn cast_to(&self) -> &TypeInfo ``` -------------------------------- ### Goto Statement Node Operations (Rust) Source: https://docs.rs/full_moon/latest/full_moon/ast/lua52/struct.Goto Implements the Node trait for the Goto struct, providing methods to get the start and end positions, check for similarity, retrieve tokens, get the range, and access surrounding trivia. ```rust impl Node for Goto { fn start_position(&self) -> Option; fn end_position(&self) -> Option; fn similar(&self, other: &Self) -> bool; fn tokens<'a>(&'a self) -> Tokens<'a>; fn range(&self) -> Option<(Position, Position)>; fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>); } ``` -------------------------------- ### String Conversion Utilities Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Return_search= Provides methods to convert values into strings and handle conversion errors. ```APIDOC ## String Conversion and Error Handling ### `fn to_string(&self) -> String` **Description**: Converts the given value to a `String`. **Method**: N/A (Associated function) **Endpoint**: N/A ### `impl TryFrom for T` **Description**: Provides a mechanism to attempt conversion from one type `U` to another type `T`, returning a `Result` to indicate success or failure. #### Type Alias: `Error` - **`type Error = Infallible`**: The type returned in the event of a conversion error. `Infallible` indicates that this conversion is guaranteed to succeed if the `U: Into` bound is met. #### Method: `try_from(value: U) -> Result>::Error>` - **Description**: Performs the conversion from `value` of type `U` to type `T`. Returns `Ok(T)` on success or `Err(Error)` if the conversion fails. ### `impl TryInto for T` **Description**: Provides a mechanism to attempt conversion from one type `T` to another type `U`, where `U` must implement `TryFrom`. This is the reciprocal of `TryFrom`. #### Type Alias: `Error` - **`type Error = >::Error`**: The type returned in the event of a conversion error. This mirrors the error type defined in the corresponding `TryFrom` implementation for `U`. #### Method: `try_into(self) -> Result>::Error>` - **Description**: Performs the conversion from `self` of type `T` to type `U`. Returns `Ok(U)` on success or `Err(Error)` if the conversion fails. ### `impl DeserializeOwned for T` **Description**: A marker trait indicating that a type `T` can be deserialized from a static data source (i.e., without borrowing data from the input). This is often used in serialization contexts like JSON parsing. **Requirements**: `T` must implement `for<'de> Deserialize<'de>`. ``` -------------------------------- ### TryFrom and TryInto Conversions Source: https://docs.rs/full_moon/latest/full_moon/ast/luau/struct.ExportedTypeDeclaration_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for attempting conversions between types that may fail. ```APIDOC ## `TryFrom` Trait ### Description Trait for fallible conversions from one type to another. ### Implementation `impl TryFrom for T where U: Into` #### Associated Type `Error` ##### Description The type returned in the event of a conversion error. ##### Type Alias `type Error = Infallible` #### `try_from` Method ##### Description Performs the conversion. ##### Method Signature `fn try_from(value: U) -> Result>::Error>` ``` ```APIDOC ## `TryInto` Trait ### Description Trait for fallible conversions into another type. ### Implementation `impl TryInto for T where U: TryFrom` #### Associated Type `Error` ##### Description The type returned in the event of a conversion error. ##### Type Alias `type Error = >::Error` #### `try_into` Method ##### Description Performs the conversion. ##### Method Signature `fn try_into(self) -> Result>::Error>` ``` -------------------------------- ### Implement Node Trait for UnOp (Rust) Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.UnOp Provides implementations for the Node trait for the UnOp enum. This includes methods to get the start and end positions, check for similarity, retrieve token references, get the node's range, and access surrounding trivia. ```rust impl Node for UnOp { fn start_position(&self) -> Option fn end_position(&self) -> Option fn similar(&self, other: &Self) -> bool fn tokens<'a>(&'a self) -> Tokens<'a> fn range(&self) -> Option<(Position, Position)> fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>) } ``` -------------------------------- ### Get Token Position in Rust Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/struct.Token_search=u32+-%3E+bool Methods to retrieve the starting and ending positions of a token. These functions return a Position object, indicating the token's location within the source. ```rust pub fn start_position(&self) -> Position ``` ```rust pub fn end_position(&self) -> Position ``` -------------------------------- ### CloneToUninit Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.LuaVersion_search=std%3A%3Avec Provides a nightly-only experimental API for performing copy-assignment from self to a destination pointer. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `unsafe fn` ### Endpoint N/A (Standard Library Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (N/A) This is a method, not an API endpoint. #### Response Example None ``` -------------------------------- ### starts_with() - Check for prefix Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString Determines if a string slice begins with a specified pattern. ```APIDOC ## GET /string/starts_with ### Description Checks if the string slice starts with a given pattern. The pattern can be a string slice, a character, a slice of characters, or a closure. ### Method GET ### Endpoint /string/starts_with ### Parameters #### Query Parameters - **text** (string) - Required - The string slice to check. - **pattern** (string | char | array of char) - Required - The pattern to check for at the beginning. ### Request Example ```json { "text": "bananas", "pattern": "bana" } ``` ### Response #### Success Response (200) - **result** (boolean) - `true` if the string slice starts with the pattern, `false` otherwise. #### Response Example ```json { "result": true } ``` ``` -------------------------------- ### Rust: Get ContainedSpan token bounds Source: https://docs.rs/full_moon/latest/full_moon/ast/span/struct.ContainedSpan A method to retrieve the start and end `TokenReference`s of a `ContainedSpan`. It returns these bounds as a tuple of references, allowing access to the token information defining the span. ```rust pub fn tokens(&self) -> (&TokenReference, &TokenReference) ``` -------------------------------- ### Rust: NumericFor Node Trait Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.NumericFor Shows implementations of the `Node` trait for `NumericFor`, providing methods to get the start and end positions, check for semantic similarity with other nodes, and retrieve all constituent tokens. ```rust fn start_position(&self) -> Option fn end_position(&self) -> Option fn similar(&self, other: &Self) -> bool fn tokens<'a>(&'a self) -> Tokens<'a> ``` -------------------------------- ### BinOp Trait Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search= Documentation for the standard traits implemented for the BinOp enum, including Clone, Debug, Deserialize, Display, Node, and PartialEq. ```APIDOC ## Trait Implementations ### `impl Clone for BinOp` #### `fn clone(&self) -> BinOp` Creates a duplicate of the value. #### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `impl Debug for BinOp` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ### `impl<'de> Deserialize<'de> for BinOp` #### `fn deserialize<__D>(__deserializer: __D) -> Result` Deserializes this value from the given Serde deserializer. ### `impl Display for BinOp` #### `fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ### `impl Node for BinOp` #### `fn start_position(&self) -> Option` Returns the start position of a node, if determinable. #### `fn end_position(&self) -> Option` Returns the end position of a node, if determinable. #### `fn similar(&self, other: &Self) -> bool` Checks if another node of the same type is semantically similar, ignoring position. #### `fn tokens<'a>(&'a self) -> Tokens<'a>` Returns the token references that comprise a node. #### `fn range(&self) -> Option<(Position, Position)>` Returns the full range of a node, if both start and end positions are available. #### `fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>)` Returns the leading and trailing trivia tokens (comments, whitespace) surrounding a node. ### `impl PartialEq for BinOp` #### `fn eq(&self, other: &BinOp) -> bool` Tests for equality between `self` and `other`. ``` -------------------------------- ### Get Attribute Range in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/lua54/struct.Attribute_search=u32+-%3E+bool Part of the Node trait implementation, this method returns the full range of the Attribute node as a tuple of start and end positions. It returns None if both positions cannot be determined. ```rust fn range(&self) -> Option<(Position, Position)> ``` -------------------------------- ### Get the Kind of a TokenType (Rust) Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/enum.TokenType_search=std%3A%3Avec Implements the `kind` method for the TokenType enum. This method returns the general category or kind of the token, abstracting away specific details. For example, it can distinguish between an Identifier token and other token types. ```rust use full_moon::{ShortString, tokenizer::{TokenKind, TokenType}}; assert_eq!( TokenType::Identifier { identifier: ShortString::new("hello") }.kind(), TokenKind::Identifier, ); ``` -------------------------------- ### BinOp Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=u32+-%3E+bool Details on the implementations for the BinOp enum, including methods for determining operator precedence, retrieving associated tokens, and checking associativity. ```APIDOC ## Implementations for BinOp ### `impl BinOp` #### `pub fn precedence_of_token(token: &TokenReference) -> Option` Returns the precedence of a non-unary operator. Higher numbers indicate higher precedence. This shares the same precedence table as unary operators. #### `pub fn token(&self) -> &TokenReference` Returns the `TokenReference` associated with this operator. ### `impl BinOp` (Associativity and Precedence) #### `pub fn precedence(&self) -> u8` Returns the precedence of the operator. Higher numbers indicate higher precedence. Refer to the Lua manual for details (e.g., http://www.lua.org/manual/5.1/manual.html#2.5.6). #### `pub fn is_right_associative(&self) -> bool` Returns `true` if the operator is right-associative, `false` if it is left-associative. Refer to Lua documentation for associativity rules (e.g., https://www.lua.org/pil/3.5.html). #### `pub fn is_right_associative_token(token: &TokenReference) -> bool` Given a `TokenReference`, returns `true` if it represents a right-associative binary operator. ``` -------------------------------- ### Implement Node Trait for Return in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Return_search=u32+-%3E+bool Implements the `Node` trait for the `Return` struct, providing methods to interact with the AST node. This includes getting the start and end positions, checking for semantic similarity, accessing tokens, determining the node's range, and retrieving surrounding trivia. ```rust fn start_position(&self) -> Option // The start position of a node. None if can’t be determined fn end_position(&self) -> Option // The end position of a node. None if it can’t be determined fn similar(&self, other: &Self) -> bool // Whether another node of the same type is the same as this one semantically, ignoring position fn tokens<'a>(&'a self) -> Tokens<'a> // The token references that comprise a node fn range(&self) -> Option<(Position, Position)> // The full range of a node, if it has both start and end positions fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>) // The tokens surrounding a node that are ignored and not accessible through the node’s own accessors. Use this if you want to get surrounding comments or whitespace. Returns a tuple of the leading and trailing trivia. ``` -------------------------------- ### BinOp Serialization Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=u32+-%3E+bool Provides the implementation for serializing BinOp instances using the Serde framework. ```APIDOC ## impl Serialize for BinOp ### fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer, Serialize this value into the given Serde serializer. Read more ``` -------------------------------- ### Rust Token From and Into Implementations Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/struct.Token_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the `From` and `Into` implementations for the Token struct, facilitating type conversions and allowing a Token to be converted into itself. ```rust impl From for T impl Into for T where U: From ``` -------------------------------- ### Rust Var Enum Node Trait Implementation Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.Var Implements the `Node` trait for the `Var` enum, providing methods to interact with the abstract syntax tree (AST) structure. This includes retrieving start and end positions, checking for similarity, accessing tokens, and getting surrounding trivia. ```rust impl Node for Var { fn start_position(&self) -> Option; fn end_position(&self) -> Option; fn similar(&self, other: &Self) -> bool; fn tokens<'a>(&'a self) -> Tokens<'a>; fn range(&self) -> Option<(Position, Position)>; fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>); } ``` -------------------------------- ### Rust: TypeDeclaration Node Trait Implementation Source: https://docs.rs/full_moon/latest/full_moon/ast/luau/struct.TypeDeclaration Implements the `Node` trait for `TypeDeclaration`, providing methods to interact with the abstract syntax tree (AST) structure. This includes getting the start and end positions, checking for semantic similarity, accessing the constituent tokens, and retrieving surrounding trivia like comments or whitespace. ```rust impl Node for TypeDeclaration { fn start_position(&self) -> Option fn end_position(&self) -> Option fn similar(&self, other: &Self) -> bool fn tokens<'a>(&'a self) -> Tokens<'a> fn range(&self) -> Option<(Position, Position)> fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>) } ``` -------------------------------- ### BinOp Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=std%3A%3Avec This section details the implementations for the BinOp enum, including methods for determining operator precedence, token association, and associativity. ```APIDOC ## Implementations for BinOp ### `impl BinOp` #### `pub fn precedence_of_token(token: &TokenReference) -> Option` Returns the precedence of a non-unary operator. Higher numbers indicate higher precedence. Shares the same precedence table as unary operators. #### `pub fn token(&self) -> &TokenReference` Returns the `TokenReference` associated with this operator. ### `impl BinOp` (Associativity and Precedence) #### `pub fn precedence(&self) -> u8` Returns the precedence of the operator. Higher numbers indicate higher precedence. Refer to http://www.lua.org/manual/5.1/manual.html#2.5.6 for details. #### `pub fn is_right_associative(&self) -> bool` Returns `true` if the operator is right-associative, `false` if it is left-associative. Refer to https://www.lua.org/pil/3.5.html for more information. #### `pub fn is_right_associative_token(token: &TokenReference) -> bool` Given a `TokenReference`, returns `true` if it represents a right-associative binary operator. ### Trait Implementations #### `impl Clone for BinOp` ##### `fn clone(&self) -> BinOp` Creates a duplicate of the `BinOp` value. ##### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from a source `BinOp` value. #### `impl Debug for BinOp` ##### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the `BinOp` value using the provided formatter. #### `impl<'de> Deserialize<'de> for BinOp` ##### `fn deserialize<__D>(__deserializer: __D) -> Result` Deserializes the `BinOp` value from a Serde deserializer. #### `impl Display for BinOp` ##### `fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result` Formats the `BinOp` value for display using the provided formatter. #### `impl Node for BinOp` ##### `fn start_position(&self) -> Option` Returns the starting position of the node, if determinable. ##### `fn end_position(&self) -> Option` Returns the ending position of the node, if determinable. ##### `fn similar(&self, other: &Self) -> bool` Compares two `BinOp` nodes for semantic similarity, ignoring their positions. ##### `fn tokens<'a>(&'a self) -> Tokens<'a>` Returns an iterator over the token references that constitute the `BinOp` node. ##### `fn range(&self) -> Option<(Position, Position)>` Returns the full range (start and end positions) of the node, if both are available. ##### `fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>)` Returns the leading and trailing trivia tokens (like comments and whitespace) surrounding the node. #### `impl PartialEq for BinOp` ##### `fn eq(&self, other: &BinOp) -> bool` Compares two `BinOp` values for equality. ``` -------------------------------- ### Return Trait Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Return_search=u32+-%3E+bool Details the various trait implementations for the Return struct, including Clone, Debug, Default, Deserialize, Display, Node, PartialEq, Serialize, and StructuralPartialEq. ```APIDOC ## Trait Implementations ### `impl Clone for Return` #### `fn clone(&self) -> Return` Returns a duplicate of the value. #### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `impl Debug for Return` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ### `impl Default for Return` #### `fn default() -> Self` Returns the “default value” for a type. ### `impl<'de> Deserialize<'de> for Return` #### `fn deserialize<__D>(__deserializer: __D) -> Result` Deserialize this value from the given Serde deserializer. ### `impl Display for Return` #### `fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ### `impl Node for Return` #### `fn start_position(&self) -> Option` The start position of a node. #### `fn end_position(&self) -> Option` The end position of a node. #### `fn similar(&self, other: &Self) -> bool` Whether another node of the same type is the same as this one semantically, ignoring position. #### `fn tokens<'a>(&'a self) -> Tokens<'a>` The token references that comprise a node. #### `fn range(&self) -> Option<(Position, Position)>` The full range of a node, if it has both start and end positions. #### `fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>)` The tokens surrounding a node that are ignored and not accessible through the node’s own accessors. ### `impl PartialEq for Return` #### `fn eq(&self, other: &Return) -> bool` Tests for `self` and `other` values to be equal, and is used by `==`. #### `fn ne(&self, other: &Rhs) -> bool` Tests for `!=`. ### `impl Serialize for Return` #### `fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>` Serialize this value into the given Serde serializer. ### `impl StructuralPartialEq for Return` ``` -------------------------------- ### Define and Initialize Return Statement (Rust) Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Return Demonstrates how to define and initialize a `Return` struct, which represents a return statement. This struct is part of the `full_moon::ast` module and is used for abstract syntax tree manipulation. ```rust pub struct Return { /* private fields */ } impl Return { /// Creates a new empty Return /// Default return token is followed by a single space pub fn new() -> Self; /// The `return` token pub fn token(&self) -> &TokenReference; /// The values being returned pub fn returns(&self) -> &Punctuated; /// Returns a new Return with the given `return` token pub fn with_token(self, token: TokenReference) -> Self; /// Returns a new Return with the given punctuated sequence pub fn with_returns(self, returns: Punctuated) -> Self; } ``` -------------------------------- ### Get Immutable Reference to Value - Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/punctuated/enum.Pair_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to get an immutable reference to the value `T` within a `Pair` using the `value` method. ```rust let pair = Pair::new(1, None); assert_eq!(pair.value(), &1); ``` -------------------------------- ### CloneToUninit Trait Source: https://docs.rs/full_moon/latest/full_moon/ast/luau/struct.TypeDeclaration_search= Documentation for the `CloneToUninit` trait, which allows for copy-assignment to uninitialized memory. This is a nightly-only experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ### Method `unsafe fn` ### Endpoint N/A (Trait method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A (This is a method, not an API endpoint) #### Response Example N/A ``` -------------------------------- ### Rust: Convert Between Types Using From and Into Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Block Demonstrates how to convert between types using the `From` and `Into` traits in Rust. `From` is for direct conversions, while `Into` is automatically implemented when `From` is available, allowing for more idiomatic conversions. ```rust impl Into for T where U: From, { fn into(self) -> U { U::from(self) } } // Example Usage: // let my_string = String::from("hello"); // let my_bytes: Vec = my_string.into(); ``` -------------------------------- ### Safely Get String Subslice in Rust Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates the `get()` method for safely retrieving a subslice of a string. It returns `Some(&str)` if the indices are valid and on character boundaries, and `None` otherwise. ```rust let v = String::from("🗻∈🌏"); assert_eq!(Some("🗻"), v.get(0..4)); // indices not on UTF-8 sequence boundaries assert!(v.get(1..).is_none()); assert!(v.get(..8).is_none()); // out of bounds assert!(v.get(..42).is_none()); ``` -------------------------------- ### Parsing with Punctuated Sequence in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/punctuated/index Demonstrates how to parse a string into a syntax tree structure using the Punctuated type. This example highlights the use of punctuation to separate elements within a sequence, such as arguments in a function call. ```rust let ast = parse("call(arg1, arg2, arg3)")?; // ^^^^^ ~~~~~ ^^^^^ ``` -------------------------------- ### Get Parsed AST Reference - Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.AstResult_search= Provides a method to get an immutable reference to the `Ast` that was parsed. If errors occurred, the returned `Ast` might have undergone reconstruction. This is useful for inspecting the parsed structure without consuming the `AstResult`. ```rust pub fn ast(&self) -> &Ast ``` -------------------------------- ### BinOp Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search= This section details the implementations for the BinOp enum, including methods for determining operator precedence, retrieving associated tokens, and checking associativity. ```APIDOC ## Implementations ### `impl BinOp` #### `pub fn precedence_of_token(token: &TokenReference) -> Option` Returns the precedence of a non-unary operator. Higher numbers indicate higher precedence. This shares the same precedence table as unary operators. #### `pub fn token(&self) -> &TokenReference` Returns the token associated with this operator. ### `impl BinOp` #### `pub fn precedence(&self) -> u8` Returns the precedence of the operator. Higher numbers indicate higher precedence. Refer to http://www.lua.org/manual/5.1/manual.html#2.5.6 for details. #### `pub fn is_right_associative(&self) -> bool` Indicates whether the operator is right-associative. If false, it is left-associative. See https://www.lua.org/pil/3.5.html for more information. #### `pub fn is_right_associative_token(token: &TokenReference) -> bool` Given a token, returns whether it represents a right-associative binary operator. ``` -------------------------------- ### Implement Node Trait for CompoundAssignment in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.CompoundAssignment_search= Covers the implementation of the `Node` trait for `CompoundAssignment`, providing methods related to Abstract Syntax Tree (AST) node manipulation. This includes functions to get start/end positions, check for similarity, retrieve tokens, and get surrounding trivia. ```rust impl Node for CompoundAssignment fn start_position(&self) -> Option fn end_position(&self) -> Option fn similar(&self, other: &Self) -> bool fn tokens<'a>(&'a self) -> Tokens<'a> fn range(&self) -> Option<(Position, Position)> fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>) ``` -------------------------------- ### BinOp Trait Implementations Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=u32+-%3E+bool Information about the standard traits implemented for the BinOp enum, including Clone, Debug, Deserialize, Display, Node, and PartialEq. ```APIDOC ## Trait Implementations for BinOp ### `impl Clone for BinOp` #### `fn clone(&self) -> BinOp` Creates a duplicate of the `BinOp` value. #### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from a source `BinOp` value. ### `impl Debug for BinOp` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the `BinOp` value for debugging purposes using the provided formatter. ### `impl<'de> Deserialize<'de> for BinOp` #### `fn deserialize<__D>(__deserializer: __D) -> Result` Deserializes a `BinOp` value from a Serde deserializer. ### `impl Display for BinOp` #### `fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result` Formats the `BinOp` value for display using the provided formatter. ### `impl Node for BinOp` #### `fn start_position(&self) -> Option` Returns the starting position of the AST node, if determinable. #### `fn end_position(&self) -> Option` Returns the ending position of the AST node, if determinable. #### `fn similar(&self, other: &Self) -> bool` Compares two `BinOp` nodes for semantic similarity, ignoring their positions. #### `fn tokens<'a>(&'a self) -> Tokens<'a>` Returns an iterator over the token references that constitute this AST node. #### `fn range(&self) -> Option<(Position, Position)>` Returns the full range (start and end positions) of the node, if both are available. #### `fn surrounding_trivia(&self) -> (Vec<&Token>, Vec<&Token>)` Returns the leading and trailing trivia (e.g., comments, whitespace) surrounding the node. ### `impl PartialEq for BinOp` #### `fn eq(&self, other: &BinOp) -> bool` Tests for equality between two `BinOp` values. ``` -------------------------------- ### Create and Access NumericFor in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.NumericFor_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create a new NumericFor instance and access its components. The `new` function takes the index variable, start, and end expressions. Accessor methods like `for_token`, `index_variable`, `start`, `end`, and `block` allow retrieval of specific parts of the loop structure. ```rust pub fn new( index_variable: TokenReference, start: Expression, end: Expression, ) -> Self pub fn for_token(&self) -> &TokenReference pub fn index_variable(&self) -> &TokenReference pub fn start(&self) -> &Expression pub fn end(&self) -> &Expression pub fn block(&self) -> &Block ``` -------------------------------- ### Type Conversions Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.LuaVersion_search=u32+-%3E+bool Documentation for type conversion traits like `From`, `Into`, `TryFrom`, and `TryInto`. ```APIDOC ## impl From for T ### Description Returns the argument unchanged. ### Method `fn from(t: T) -> T` ### Endpoint N/A (Standard Library Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## impl Into for T where U: From ### Description Provides a convenient way to convert between types using the `From` trait. ### Method `fn into(self) -> U` Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Endpoint N/A (Standard Library Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## impl TryFrom for T where U: Into ### Description Provides a fallible way to convert between types. ### Type `type Error = Infallible` The type returned in the event of a conversion error. ### Method `fn try_from(value: U) -> Result>::Error>` Performs the conversion. ### Endpoint N/A (Standard Library Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## impl TryInto for T where U: TryFrom ### Description Provides a fallible way to convert between types, leveraging `TryFrom`. ### Type `type Error = >::Error` The type returned in the event of a conversion error. ### Method `fn try_into(self) -> Result>::Error>` Performs the conversion. ### Endpoint N/A (Standard Library Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Generic Type ID Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.NumericFor Gets the TypeId of a generic type. ```APIDOC ## GET /websites/rs_full_moon_full_moon/type_id ### Description Retrieves the `TypeId` of a generic type `T`. ### Method GET ### Endpoint /websites/rs_full_moon_full_moon/type_id ### Parameters None ### Response #### Success Response (200) - **type_id** (TypeId) - The unique identifier for the type. #### Response Example ```json { "type_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ``` -------------------------------- ### BinOp Equality Source: https://docs.rs/full_moon/latest/full_moon/ast/enum.BinOp_search=u32+-%3E+bool Details the equality comparison implementations for the BinOp type. ```APIDOC ### impl Eq for BinOp ### impl StructuralPartialEq for BinOp ``` -------------------------------- ### Rust: Create and manipulate a Block Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.Block Demonstrates how to create a new `Block` instance, either empty or with specific statements and a last statement. It also shows how to retrieve statements and the last statement from an existing block. ```rust use full_moon::ast::{Block, Stmt, LastStmt}; use full_moon::token::TokenReference; // Create an empty block let mut block = Block::new(); // Create a block with statements and a last statement let stmt1 = Stmt::new(...); // Assuming Stmt can be created let stmt2 = Stmt::new(...); let last_stmt = LastStmt::new(...); // Assuming LastStmt can be created let mut block_with_stmts = Block::with_stmts(vec![(stmt1, None), (stmt2, Some(TokenReference::new()))]); block_with_stmts = Block::with_last_stmt(block_with_stmts, Some((last_stmt, None))); // Iterate over statements for stmt in block.stmts() { // process stmt } // Get the last statement if let Some(last) = block.last_stmt() { // process last statement } ``` -------------------------------- ### Get Function Name in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.FunctionDeclaration_search= Returns the `FunctionName` associated with this function declaration. ```rust pub fn name(&self) -> &FunctionName ``` -------------------------------- ### Create Lexer Instance - Rust Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/struct.Lexer_search= Provides methods to create a new Lexer instance. `new` processes the first token immediately, while `new_lazy` defers processing until the first token is requested. Both require a source string and a LuaVersion. ```rust pub fn new(source: &str, lua_version: LuaVersion) -> Self ``` ```rust pub fn new_lazy(source: &str, lua_version: LuaVersion) -> Self ``` -------------------------------- ### TokenType Methods Source: https://docs.rs/full_moon/latest/full_moon/tokenizer/enum.TokenType_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for interacting with TokenType variants, such as checking if a token is trivia or getting its kind. ```APIDOC ## impl TokenType ### `is_trivia(&self) -> bool` Returns `true` if the token can be practically ignored in most cases (e.g., comments and whitespace), and `false` otherwise. ### `kind(&self) -> TokenKind` Returns the general kind of the token type. #### Example ```rust use full_moon::{ShortString, tokenizer::{TokenKind, TokenType}}; assert_eq!( TokenType::Identifier { identifier: ShortString::new("hello") }.kind(), TokenKind::Identifier, ); ``` ### `spaces(spaces: usize) -> Self` Creates a `TokenType::Whitespace` variant consisting of the specified number of space characters. ### `tabs(tabs: usize) -> Self` Creates a `TokenType::Whitespace` variant consisting of the specified number of tab characters. ``` -------------------------------- ### Clone::clone_to_uninit Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.FunctionDeclaration This is a nightly-only experimental API that performs copy-assignment from self to dest. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description This is a nightly-only experimental API. Performs copy-assignment from `self` to `dest`. ### Method `unsafe fn` ### Endpoint N/A (Method within a trait) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (operates via pointer manipulation) #### Response Example None ``` -------------------------------- ### Get TypeId (Rust) Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.NumericFor_search= A blanket implementation for any type `T` that provides a `type_id` method, returning the `TypeId` of the instance. This is part of the `Any` trait. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId; } ``` -------------------------------- ### ShortString Blanket Implementations Source: https://docs.rs/full_moon/latest/full_moon/struct.ShortString_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for blanket implementations applicable to ShortString. ```APIDOC ## Blanket Implementations for ShortString ### impl Any for T #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T #### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl CloneToUninit for T #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T #### fn into(self) -> U Calls `U::from(self)`. ### impl Receiver for P #### type Target = T The target type on which the method may be called. ### impl ToOwned for T #### type Owned = T The resulting type after obtaining ownership. #### fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. #### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. ### impl ToSmolStr for T #### fn to_smolstr(&self) -> SmolStr ### impl ToString for T #### fn to_string(&self) -> String Converts the given value to a `String`. ### impl TryFrom for T #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Get Compound Operator of CompoundAssignment in Rust Source: https://docs.rs/full_moon/latest/full_moon/ast/struct.CompoundAssignment_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the compound operator (e.g., `+=`) used in a CompoundAssignment. ```rust pub fn compound_operator(&self) -> &CompoundOp ```