pub struct ShaderTemplateV2 {
pub source: String,
pub defines: HashMap<String, String>,
}Expand description
A parameterised shader template that replaces #define KEY tokens.
Instantiation replaces occurrences of each key found in defines
with the corresponding value. The key must appear as a whole word
(surrounded by non-identifier characters or at start/end of line).
Fields§
§source: StringRaw template source text.
defines: HashMap<String, String>Map from token name to replacement value.
Implementations§
Source§impl ShaderTemplateV2
impl ShaderTemplateV2
Sourcepub fn new(source: impl Into<String>, defines: HashMap<String, String>) -> Self
pub fn new(source: impl Into<String>, defines: HashMap<String, String>) -> Self
Create a new template with the given source and defines.
Sourcepub fn instantiate(&self) -> String
pub fn instantiate(&self) -> String
Instantiate the template by performing all #define substitutions.
Each entry in defines replaces all occurrences of the key
in the source with the corresponding value.
Trait Implementations§
Source§impl Clone for ShaderTemplateV2
impl Clone for ShaderTemplateV2
Source§fn clone(&self) -> ShaderTemplateV2
fn clone(&self) -> ShaderTemplateV2
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ShaderTemplateV2
impl RefUnwindSafe for ShaderTemplateV2
impl Send for ShaderTemplateV2
impl Sync for ShaderTemplateV2
impl Unpin for ShaderTemplateV2
impl UnsafeUnpin for ShaderTemplateV2
impl UnwindSafe for ShaderTemplateV2
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§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>
Converts
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>
Converts
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