All Projects → slightlyoutofphase → staticstep

slightlyoutofphase / staticstep

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Provides truly zero-cost alternatives to Iterator::step_by for both incrementing and decrementing any type that satisfies RangeBounds<T: Copy + Default + Step>.

Programming Languages

rust
11053 projects
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to staticstep

StackFlowView
Enforce stack behaviour for custom UI flow.
Stars: ✭ 35 (+169.23%)
Mutual labels:  steps, step
Range V3
Range library for C++14/17/20, basis for C++20's std::ranges
Stars: ✭ 3,231 (+24753.85%)
Mutual labels:  iterator, range
Rangeseekbar
A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)
Stars: ✭ 2,037 (+15569.23%)
Mutual labels:  range, step
Easyiterator
🏃 Iterators made easy! Zero cost abstractions for designing and using C++ iterators.
Stars: ✭ 107 (+723.08%)
Mutual labels:  iterator, range
blIteratorAPI
A template library for creating custom iterators
Stars: ✭ 22 (+69.23%)
Mutual labels:  iterator, iterators
Mir Algorithm
Dlang Core Library
Stars: ✭ 143 (+1000%)
Mutual labels:  iterator, range
goone
goone finds N+1 query in go
Stars: ✭ 41 (+215.38%)
Mutual labels:  loop
RangeSeekBar
Android Range Seekbar library that support Min & Max Value for API level >= 16 and support Step Value
Stars: ✭ 97 (+646.15%)
Mutual labels:  range
TimerInterrupt
This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behavin…
Stars: ✭ 76 (+484.62%)
Mutual labels:  loop
loops-e-arrays
Repositório do curso Estruturas de Repetição e Arrays com Java. Curso este oferecido pela Digital Innovation one e ministrado por mim.
Stars: ✭ 1,029 (+7815.38%)
Mutual labels:  loops
Iterators.jl
Common functional iterator patterns. DEPRECATED in favour of IterTools.jl
Stars: ✭ 59 (+353.85%)
Mutual labels:  iterators
LinqBenchmarks
Benchmarking LINQ and alternative implementations
Stars: ✭ 138 (+961.54%)
Mutual labels:  range
forms-wizard
🎩 Easy to use step-by-step form for Nette Framework
Stars: ✭ 14 (+7.69%)
Mutual labels:  steps
NC.js
Web interface for the Digital Thread
Stars: ✭ 33 (+153.85%)
Mutual labels:  step
jquery-datepicker
A full-featured datepicker jquery plugin
Stars: ✭ 35 (+169.23%)
Mutual labels:  range
f3d
Fast and minimalist 3D viewer.
Stars: ✭ 791 (+5984.62%)
Mutual labels:  step
videojs-abloop
A video.js plugin for looping of a section of video, with GUI and API controls
Stars: ✭ 36 (+176.92%)
Mutual labels:  loop
animate
👾 Create and manage animation functions with AnimationFrame API.
Stars: ✭ 11 (-15.38%)
Mutual labels:  loop
IterTools.jl
Common functional iterator patterns
Stars: ✭ 124 (+853.85%)
Mutual labels:  iterators
ruststep
A STEP toolkit for Rust
Stars: ✭ 77 (+492.31%)
Mutual labels:  step

Latest Version Rustc Version nightly

Build status docs.rs

Provides truly zero-cost alternatives to Iterator::step_by for both incrementing and decrementing any type that satisfies RangeBounds<T: Copy + Default + Step>.

The assembly code generated for the two trait methods this crate implements, inc_by and dec_by, should in the overwhelming majority of cases be nearly or completely identical to the assembly code that would be generated for an incrementing "step"-based while loop or decrementing "step"-based while loop, respectively. If you come across a scenario where it is not, please feel free to open an issue about it.

Minimum supported Rust version: this is a nightly-only crate at the moment due to the use of the Step trait, which has not yet been stabilized.

#![no_std] compatibility: this crate is fully #![no_std] compatible by default.

A basic usage example:

use staticstep::*;

// Apart from aiming to provide a properly-optimized Rust equivalent to the sort of C-style for-loop
// that ends in `i += number` or `i -= number` as opposed to `i++` or `i--`, this crate also aims to
// (and does) support backwards ranges in a meaningful way that's logically equivalent to how
// forwards ranges are generally dealt with in Rust.

fn main() {
  // Exclusive, so 48 is the last number printed.
  for i in (0..64).inc_by::<16>() {
    print!("{} ", i);
  }
  println!("");

  // Inclusive, so 64 is the last number printed.
  for i in (0..=64).inc_by::<16>() {
    print!("{} ", i);
  }
  println!("");

  // Exclusive, so 16 is the last number printed.
  for i in (64..0).dec_by::<16>() {
    print!("{} ", i);
  }
  println!("");

  // Inclusive, so 0 is the last number printed.
  for i in (64..=0).dec_by::<16>() {
    print!("{} ", i);
  }

  // Note that `inc_by` will always immediately return `None` if given a reverse range, while
  // `dec_by` will always immediately return `None` if given a "normal" forwards range.
}

License:

Licensed under either the MIT license or version 2.0 of the Apache License. Your choice as to which! Any source code contributions will be dual-licensed in the same fashion.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].