Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's on-box pages, and what it costs. What works: - schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs); - src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so the unified sidebar, ordering and surface filtering come from the schema rather than from hand-written HTML; - the render uses the shared bf- design tokens, the same ones the rest of the suite uses. Size, measured rather than assumed (armv7, release, stripped): ui-baseline 323 KiB (maud + serde_json, no flare-ui) ui-spike 771 KiB (flare-ui + wschema + sha2) marginal 448 KiB Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in flare-ui/flare-ui.lock (a partial archive does not compile, since the crate include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo directory source with the new registry dependencies (maud, sha2, typenum, digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build still works offline. third-party/README.md records how to re-pin.
60 lines
1.2 KiB
Rust
60 lines
1.2 KiB
Rust
use std::iter::FusedIterator;
|
|
|
|
/// An iterator that produces *n* repetitions of an element.
|
|
///
|
|
/// See [`repeat_n()`](crate::repeat_n) for more information.
|
|
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
|
#[derive(Clone, Debug)]
|
|
pub struct RepeatN<A> {
|
|
elt: Option<A>,
|
|
n: usize,
|
|
}
|
|
|
|
/// Create an iterator that produces `n` repetitions of `element`.
|
|
pub fn repeat_n<A>(element: A, n: usize) -> RepeatN<A>
|
|
where A: Clone,
|
|
{
|
|
if n == 0 {
|
|
RepeatN { elt: None, n, }
|
|
} else {
|
|
RepeatN { elt: Some(element), n, }
|
|
}
|
|
}
|
|
|
|
impl<A> Iterator for RepeatN<A>
|
|
where A: Clone
|
|
{
|
|
type Item = A;
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
if self.n > 1 {
|
|
self.n -= 1;
|
|
self.elt.as_ref().cloned()
|
|
} else {
|
|
self.n = 0;
|
|
self.elt.take()
|
|
}
|
|
}
|
|
|
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
(self.n, Some(self.n))
|
|
}
|
|
}
|
|
|
|
impl<A> DoubleEndedIterator for RepeatN<A>
|
|
where A: Clone
|
|
{
|
|
#[inline]
|
|
fn next_back(&mut self) -> Option<Self::Item> {
|
|
self.next()
|
|
}
|
|
}
|
|
|
|
impl<A> ExactSizeIterator for RepeatN<A>
|
|
where A: Clone
|
|
{}
|
|
|
|
impl<A> FusedIterator for RepeatN<A>
|
|
where A: Clone
|
|
{}
|