Skip to content

feat: add customizable ellipsis, element prefix/suffix, and show-count for DisplaySlice#9

Merged
drmingdrmer merged 3 commits intodatabendlabs:mainfrom
drmingdrmer:011-display-braces
Feb 17, 2026
Merged

feat: add customizable ellipsis, element prefix/suffix, and show-count for DisplaySlice#9
drmingdrmer merged 3 commits intodatabendlabs:mainfrom
drmingdrmer:011-display-braces

Conversation

@drmingdrmer
Copy link
Member

Changelog

feat: add customizable ellipsis, element prefix/suffix, and show-count for DisplaySlice

Three new builder methods extend DisplaySlice formatting:

  • .ellipsis(s) replaces the hardcoded .. truncation indicator with any string
  • .elem(prefix, suffix) wraps each displayed element (but not the ellipsis)
  • .show_count() appends (N total) to the ellipsis when truncation occurs

The show_count feature only allocates a format! string when both active and
truncation is needed; the common path remains allocation-free.

Example:

vec![1,2,3,4,5,6,7].display()
    .ellipsis("...").show_count().elem("'", "'").sep(", ").braces("{", "}")
// => {'1', '2', '3', '4', ...(7 total), '7'}
feat: add customizable braces for DisplaySlice

DisplaySlice previously hardcoded [ and ] as surrounding braces.
This adds a braces() builder method to configure them, following the
same pattern as sep(). Defaults remain [ / ] for backward
compatibility.

Example:

vec![1, 2, 3].display().braces("{", "}").to_string()
// => "{1,2,3}"

vec![1, 2, 3].display().braces("<", ">").sep(", ").to_string()
// => "<1, 2, 3>"
chore: Bump ver: 0.2.4

`DisplaySlice` previously hardcoded `[` and `]` as surrounding braces.
This adds a `braces()` builder method to configure them, following the
same pattern as `sep()`. Defaults remain `[` / `]` for backward
compatibility.

Example:

    vec![1, 2, 3].display().braces("{", "}").to_string()
    // => "{1,2,3}"

    vec![1, 2, 3].display().braces("<", ">").sep(", ").to_string()
    // => "<1, 2, 3>"
…t for `DisplaySlice`

Three new builder methods extend `DisplaySlice` formatting:
- `.ellipsis(s)` replaces the hardcoded `..` truncation indicator with any string
- `.elem(prefix, suffix)` wraps each displayed element (but not the ellipsis)
- `.show_count()` appends `(N total)` to the ellipsis when truncation occurs

The `show_count` feature only allocates a `format!` string when both active and
truncation is needed; the common path remains allocation-free.

Example:

    vec![1,2,3,4,5,6,7].display()
        .ellipsis("...").show_count().elem("'", "'").sep(", ").braces("{", "}")
    // => {'1', '2', '3', '4', ...(7 total), '7'}
Copy link

@xp-trumpet xp-trumpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xp-trumpet reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on drmingdrmer).

@drmingdrmer drmingdrmer merged commit 1398d21 into databendlabs:main Feb 17, 2026
1 check passed
@drmingdrmer drmingdrmer deleted the 011-display-braces branch February 17, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants