TraditionalFor

Struct TraditionalFor 

Source
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: Init

The initial declaration of the loop variable

§predicate: Predicate

The predicate that is checked before the next iteration

§update: Update

The update that is applied after every iteration

§body: Body

The body of the for loop

Trait Implementations§

Source§

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>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Init: Debug, Predicate: Debug, Update: Debug, Body: Debug> Debug for TraditionalFor<Init, Predicate, Update, Body>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<O, Init, Predicate, Update, Body> Writable<O> for TraditionalFor<Init, Predicate, Update, Body>
where O: Output, Init: Writable<O>, Predicate: Writable<O>, Update: Writable<O>, Body: Writable<O>,

Source§

async fn write_to(&self, output: &mut O) -> Result<(), O::Error>

Writes to the output. Returns the output’s error upon failure. Read more

Auto Trait Implementations§

§

impl<Init, Predicate, Update, Body> Freeze for TraditionalFor<Init, Predicate, Update, Body>
where Init: Freeze, Predicate: Freeze, Update: Freeze, Body: Freeze,

§

impl<Init, Predicate, Update, Body> RefUnwindSafe for TraditionalFor<Init, Predicate, Update, Body>
where Init: RefUnwindSafe, Predicate: RefUnwindSafe, Update: RefUnwindSafe, Body: RefUnwindSafe,

§

impl<Init, Predicate, Update, Body> Send for TraditionalFor<Init, Predicate, Update, Body>
where Init: Send, Predicate: Send, Update: Send, Body: Send,

§

impl<Init, Predicate, Update, Body> Sync for TraditionalFor<Init, Predicate, Update, Body>
where Init: Sync, Predicate: Sync, Update: Sync, Body: Sync,

§

impl<Init, Predicate, Update, Body> Unpin for TraditionalFor<Init, Predicate, Update, Body>
where Init: Unpin, Predicate: Unpin, Update: Unpin, Body: Unpin,

§

impl<Init, Predicate, Update, Body> UnwindSafe for TraditionalFor<Init, Predicate, Update, Body>
where Init: UnwindSafe, Predicate: UnwindSafe, Update: UnwindSafe, Body: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.