pub struct TraditionalFor<Init, Predicate, Update, Body> {
pub init: Init,
pub predicate: Predicate,
pub update: Update,
pub body: Body,
}Expand description
A traditional for loop in the style for (Init; Predicate; Update) { Body }.
All the fields of this struct must be writable. For example:
use async_codegen::common::{SingularSeq, Str};
use async_codegen::context::EmptyContext;
use async_codegen::java::{AssignExpr, DeclareParam, FunctionCall, MemberAccess, Stmt, TraditionalFor};
use async_codegen::util::InMemoryOutput;
let for_loop = TraditionalFor {
init: AssignExpr(DeclareParam(Str("int"), Str("i")), Str("0")),
predicate: Str("i < 5"),
update: Str("i++"),
body: Stmt(MemberAccess(Str("System.out"), FunctionCall {
name: Str("println"),
args: SingularSeq(Str("i"))
}))
};
let string = InMemoryOutput::print_output(EmptyContext, &for_loop);
assert_eq!("for (int i = 0; i < 5; i++) {\nSystem.out.println(i);\n}\n", string);Fields§
§init: InitThe initial declaration of the loop variable
predicate: PredicateThe predicate that is checked before the next iteration
update: UpdateThe update that is applied after every iteration
body: BodyThe body of the for loop
Trait Implementations§
Source§impl<Init: Clone, Predicate: Clone, Update: Clone, Body: Clone> Clone for TraditionalFor<Init, Predicate, Update, Body>
impl<Init: Clone, Predicate: Clone, Update: Clone, Body: Clone> Clone for TraditionalFor<Init, Predicate, Update, Body>
Source§fn clone(&self) -> TraditionalFor<Init, Predicate, Update, Body>
fn clone(&self) -> TraditionalFor<Init, Predicate, Update, Body>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Init: Debug, Predicate: Debug, Update: Debug, Body: Debug> Debug for TraditionalFor<Init, Predicate, Update, Body>
impl<Init: Debug, Predicate: Debug, Update: Debug, Body: Debug> Debug for TraditionalFor<Init, Predicate, Update, Body>
Source§impl<O, Init, Predicate, Update, Body> Writable<O> for TraditionalFor<Init, Predicate, Update, Body>
impl<O, Init, Predicate, Update, Body> Writable<O> for TraditionalFor<Init, Predicate, Update, Body>
Auto Trait Implementations§
impl<Init, Predicate, Update, Body> Freeze for TraditionalFor<Init, Predicate, Update, Body>
impl<Init, Predicate, Update, Body> RefUnwindSafe for TraditionalFor<Init, Predicate, Update, Body>
impl<Init, Predicate, Update, Body> Send for TraditionalFor<Init, Predicate, Update, Body>
impl<Init, Predicate, Update, Body> Sync for TraditionalFor<Init, Predicate, Update, Body>
impl<Init, Predicate, Update, Body> Unpin for TraditionalFor<Init, Predicate, Update, Body>
impl<Init, Predicate, Update, Body> UnwindSafe for TraditionalFor<Init, Predicate, Update, Body>
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