{"id":18026785,"url":"https://github.com/yegor256/microstack","last_synced_at":"2025-09-13T13:28:20.231Z","repository":{"id":162421547,"uuid":"636961844","full_name":"yegor256/microstack","owner":"yegor256","description":"The most primitive and the fastest implementation of a fixed-size last-in-first-out stack on stack in Rust, for Copy-implementing types","archived":false,"fork":false,"pushed_at":"2025-03-09T20:46:23.000Z","size":106,"stargazers_count":11,"open_issues_count":12,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-22T17:44:29.145Z","etag":null,"topics":["crate","data-structures","rust","stack","stack-based"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/microstack","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-06T05:01:47.000Z","updated_at":"2024-11-13T14:38:57.000Z","dependencies_parsed_at":"2023-05-27T16:15:08.347Z","dependency_job_id":"fc357a4d-da51-4714-b4fd-45c6b2f30e48","html_url":"https://github.com/yegor256/microstack","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/yegor256/microstack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicrostack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicrostack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicrostack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicrostack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/microstack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicrostack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274968715,"owners_count":25383116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crate","data-structures","rust","stack","stack-based"],"created_at":"2024-10-30T08:08:02.977Z","updated_at":"2025-09-13T13:28:20.195Z","avatar_url":"https://github.com/yegor256.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![cargo](https://github.com/yegor256/microstack/actions/workflows/cargo.yml/badge.svg)](https://github.com/yegor256/microstack/actions/workflows/cargo.yml)\n[![crates.io](https://img.shields.io/crates/v/microstack.svg)](https://crates.io/crates/microstack)\n[![codecov](https://codecov.io/gh/yegor256/microstack/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/microstack)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/microstack)](https://hitsofcode.com/view/github/yegor256/microstack)\n![Lines of code](https://img.shields.io/tokei/lines/github/yegor256/microstack)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/microstack/blob/master/LICENSE.txt)\n[![docs.rs](https://img.shields.io/docsrs/microstack)](https://docs.rs/microstack/latest/microstack/)\n\nThis is the simplest and the fastest (faster than [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html)!) implementation of a \nlast-in-first-out [stack data structure](https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29), \non [stack](https://en.wikipedia.org/wiki/Call_stack), \nwhen stack elements are `Copy` implementing primitives. \nThis is basically a wrapper around an [uninitialized](https://doc.rust-lang.org/nomicon/uninitialized.html) array.\nWhen it is created on stack, its elements contain no specific data.\nThen, when you `push_unchecked(x)`, the head of the stack is moved forward\nand `x` is placed into the element of the array. When you `pop_unchecked()`,\nthe head is moved backward and the data is retrieved from the array.\nThere are no boundary checks, that's why both `push_unchecked()` and `pop_unchecked()` may lead to undefined\nbehavior. Use `push()` and `pop()`, which are safer, but slower.\nFor even slower but even safer behavior, you can use `try_push()` and `try_pop()`.\n\nFirst, add this to `Cargo.toml`:\n\n```toml\n[dependencies]\nmicrostack = \"0.0.7\"\n```\n\nThen, use it like this (mind the `unsafe` blocks, they give the fastest performance, \nbut [undefined behavior](https://doc.rust-lang.org/reference/behavior-considered-undefined.html) \nif you go over the stack boundaries):\n\n```rust\nuse microstack::Stack;\nlet mut s : Stack\u003c\u0026str, 10\u003e = Stack::new(); // allocation on stack\nunsafe { s.push_unchecked(\"foo\") }; // no boundary checks here\nunsafe { s.push_unchecked(\"bar\") }; // and here\nassert_eq!(\"bar\", unsafe { s.pop_unchecked() }); // and here again\nassert_eq!(1, s.len());\n```\n\nPay attention, here the stack is created with an extra \n[const generic argument](https://practice.rs/generics-traits/const-generics.html) equal to `10`. This is \nthe total size of the stack data structure, which is allocated on stack when `::new()` is called. \n\nRead [the API documentation](https://docs.rs/microstack/latest/microstack/).\n\n## How to Contribute\n\nFirst, install [Rust](https://www.rust-lang.org/tools/install) and then:\n\n```bash\n$ cargo test -vv\n```\n\nIf everything goes well, fork repository, make changes, send us a [pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nWe will review your changes and apply them to the `master` branch shortly,\nprovided they don't violate our quality standards. To avoid frustration,\nbefore sending us your pull request please run `cargo test` again. Also, \nrun `cargo fmt` and `cargo clippy`.\n\nAlso, before you start making changes, run benchmarks:\n\n```bash\n$ rustup run nightly cargo bench\n```\n\nThen, after the changes you make, run it again. Compare the results. If your changes\ndegrade performance, think twice before submitting a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fmicrostack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fmicrostack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fmicrostack/lists"}