Easy pretty print your Rust struct into single element or table

Related tags

GUI descriptor
Overview

Simple Struct Descriptor

Crates.io Crates.io License Build Status Coverage Status

Easy pretty print your Rust struct into single element or table

Example

use descriptor::{object_describe_to_string, table_describe_to_string, Descriptor};

#[derive(Descriptor)]
struct User {
    name: String,
    age: i32,
    address: Address,
}

#[derive(Descriptor)]
struct Address {
    street: String,
    town: String,
}

fn main() {
    let user1 = User {
        name: "Adrien".to_string(),
        age: 32,
        address: Address {
            street: "Main street".to_string(),
            town: "NY".to_string()
        }
    };
    let user2 = User {
        name: "Corentin".to_string(),
        age: 40,
        address: Address {
            street: "10 rue de la paix".to_string(),
            town: "Paris".to_string()
        }
    };
    let description = object_describe_to_string(&user1).unwrap();

    assert_eq!(r#"
     Name:    Adrien
     Age:     32
     Address:
       Street: Main street
       Town:   NY
     "#, description);

    let table = table_describe_to_string(&vec![user1, user2]).unwrap();

    assert_eq!(r#"
     NAME     AGE ADDRESS.STREET    ADDRESS.TOWN
     Adrien   32  Main street       NY
     Corentin 40  10 rue de la paix Paris
     "#, format!("\n{}", table));
}
You might also like...
A TUI to quickly find files in your Google Drive
A TUI to quickly find files in your Google Drive

A TUI to quickly find files in your Google Drive

Kooha - Elegantly record your screen
Kooha - Elegantly record your screen

Kooha Elegantly record your screen Capture your screen in a intuitive and straightforward way without distractions. Kooha is a simple screen recorder

A template to kickstart your Cairo 1.0 development

Cairo 1 template How to use Install Rust Click the "Use this template" button to use this as a basis for your repo or create a codespace on Github. To

Fine-tune your instruments.
Fine-tune your instruments.

Chromatic Fine-tune your instruments with Chromatic. Chromatic detects the frequency of audio input, converts it to a musical note with the correct se

With Dejavu, you can have a perfect memory by capturing and organizing your visual recordings efficiently.

Dejavu The content in README.md is assisted by ChatGPT. Overview Dejavu is an open-source, cross-platform tool designed to help you record and search

Play Hack The Box directly on your system.
Play Hack The Box directly on your system.

HTB Toolkit HTB Toolkit allows you to play Hack The Box machines directly on your system. Usage To use HTB Toolkit, you need to retrieve an App Token

A simple, cross-platform GUI automation module for Rust.

AutoPilot AutoPilot is a Rust port of the Python C extension AutoPy, a simple, cross-platform GUI automation library for Python. For more information,

A data-first Rust-native UI design toolkit.
A data-first Rust-native UI design toolkit.

Druid A data-first Rust-native UI toolkit. Druid is an experimental Rust-native UI toolkit. Its main goal is to offer a polished user experience. Ther

The Rust UI-Toolkit.
The Rust UI-Toolkit.

The Orbital Widget Toolkit is a cross-platform (G)UI toolkit for building scalable user interfaces with the programming language Rust. It's based on t

Owner
Adrien Carreira
Adrien Carreira
将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart

cxx2flow 将 C/C++ 代码转换为流程图 效果 更多效果图请参考 GALLERY 两种样式: 折线 平滑 安装 自行编译 cargo install cxx2flow 下载预构建二进制 可以到 GitHub Actions 或 Nightly.link 下载最新构建的二进制,包含 Linu

mgt 427 Dec 26, 2022
A single-header ANSI C immediate mode cross-platform GUI library

Nuklear This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed a

Immediate Mode UIs, Nuklear, etc. 6.9k Jan 8, 2023
An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

PistonDevelopers 3.3k Jan 1, 2023
egui: an easy-to-use immediate mode GUI in pure Rust

?? egui: an easy-to-use GUI in pure Rust egui is a simple, fast, and highly portable immediate mode GUI library for Rust. egui runs on the web, native

Emil Ernerfeldt 12.6k Jan 3, 2023
An easy to use command line project manager for projects using the ReCT programming language

☢️ A powerful project manager for the ReCT programming language! ☢️ ReCTx makes your projects easier to manage by allowing you to configure everything

Remy 1 Nov 28, 2022
A Rust library to parse Blueprint files and convert them into GTK UI files

?? gtk-ui-builder A Rust library to parse Blueprint files and convert them into GTK UI files Inspired by the Blueprint project Example 1 - blueprints

Observer KRypt0n_ 5 Oct 22, 2022
write your next slideshow in rust 🦀, as a self-contained binary 📦.

?? bema Write your next slideshow in rust ?? , as a self-contained binary ?? . ?? DSL See examples/basic.rs. ?? frontends There are several ways you c

Olivier Abdesselam 21 Sep 5, 2022
📎 Do something on your clipboard, automatically.

?? autoclip Do something on your clipboard, automatically. ✨ Features Automatic Customisable with Plugins ?? Installation $ cargo build --release ??

Naoki Ikeguchi 18 Nov 29, 2022
A tray icon to uwuify your text

uwu-tray fastest uwuifier in the west... now in your system tray for even faster uwufication! FAQ Which platforms are supported? Windows Linux MacOS H

Catherine Gilbert 29 Dec 10, 2022
A small tool to use along with i3/Sway to add CSS-powered decorations to your focused windows, for better usability.

glimmer What A tool for decorating i3 windows when they get focused, written in Rust. classic.mp4 Why When using i3-gaps I ran into the following prob

Daniel Acuña 26 Dec 17, 2022