Giter Site home page Giter Site logo

const-str's Introduction

Hi there!

I'm Xuyang WANG. I love to create something interesting. 👋

My ID is Nugine. Just a nuclear engine.

My blog site: https://nugine.xyz/

Programming languages: Rust, Python, TypeScript/JavaScript, C/C++, ...

Notable projects:

I have contributed to various projects:

Sponsor

If my open-source work has been helpful to you, please sponsor me.

Your contribution can help me cover the costs of hosting, development tools, and other expenses that come with creating high-quality software.

By sponsoring me, you'll also be supporting the wider open-source ecosystem. Your contribution will help to fund the development of other projects and allow developers to dedicate more time to improving the software that powers our world.

Every little bit helps, and I appreciate your support. Thank you!

PayPal

https://paypal.me/nugine0

Alipay 支付宝

alipay qrcode

WeChat Pay 微信支付

wechat pay qrcode

const-str's People

Contributors

dependabot[bot] avatar keating950 avatar nugine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

const-str's Issues

handle more than just literal

Example:

struct Foo {}

impl Foo {
    const TIP: &'static str = "hexagons are the bestagons";
}

fn main() {
    let tip = const_str::to_shouty_snake_case!(Foo::TIP);
}

Way to use convert_case with idents

Greetings!

Any way to use ident instead of literal in this macro?

trait Foo {
    const Name: &'static str;
}

macro_rules! gen {
    ($name:ident) => {
        impl Foo for $name {
            const Name: &str = const_str::convert_case!(kebab, $name)
        }
    }
}

struct TestBar {}
gen!(TestBar);

fn main() {
    assert_eq!(TestBar::Name, "test-bar");
}

replace remove the end string

0.4.2

const_str::replace!(stringify!($file), " ", "");

"run / v4" => "run/"
"token" => ""

image

rollback to 0.3 everything is ok

Feature request: "squish" a string

When writing SQL string literals, it's nice to be able to use newlines and indentation. However, all of that is unused by the database server and is better gone when logged.

Rails adds String#squish:

first removing all whitespace on both ends of the string, and then changing remaining consecutive whitespace groups into one space each.

Note that it handles both ASCII and Unicode whitespace.


As an example, I have this SQL query in Diesel

dsl::sql_query(
    "WITH

     differences AS (
       SELECT
         lag(meter) over(ORDER BY sampled_at) AS start_meter,
         meter AS end_meter,
         lag(sampled_at) over(ORDER BY sampled_at) AS starting_at,
         sampled_at AS ending_at
       FROM
         samples
       WHERE
         transaction_id = $1
     )

     SELECT
       end_meter - start_meter as delta_meter,
       starting_at,
       ending_at
     FROM
       differences
     WHERE
       start_meter IS NOT NULL",
)

This generates a log message like

Query { sql: "WITH\n\n             differences AS (\n               SELECT\n                 lag(meter) over(ORDER BY sampled_at) AS start_meter,\n                 meter AS end_meter,\n                 lag(sampled_at) over(ORDER BY sampled_at) AS starting_at,\n                 sampled_at AS ending_at\n               FROM\n                 samples\n               WHERE\n                 transaction_id = $1\n             )\n\n             SELECT\n               end_meter - start_meter as delta_meter,\n               starting_at,\n               ending_at\n             FROM\n               differences\n             WHERE\n               start_meter IS NOT NULL", binds: [TransactionId(10)] }

With squish!, the log would be

Query { sql: "WITH differences AS ( SELECT lag(meter) over(ORDER BY sampled_at) AS start_meter, meter AS end_meter, lag(sampled_at) over(ORDER BY sampled_at) AS starting_at, sampled_at AS ending_at FROM samples WHERE transaction_id = $1 ) SELECT end_meter - start_meter as delta_meter, starting_at, ending_at FROM differences WHERE start_meter IS NOT NULL", binds: [TransactionId(10)] }

Todo List

New API:

  • compare!
  • strip_prefix!
  • strip_suffix!
  • lines!
  • join!
  • split_ascii_whitespace!
  • sorted!

Docs:

  • API docs translation

Upstream issues:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.