Git Product home page Git Product logo

Comments (3)

starkat99 avatar starkat99 commented on June 14, 2024 1

I tried to make some macros, but const features are just not quite stabilized enough to do it with macro_rules, and I'd rather not add a dependency on syn just for this. utf16_lit is a good interim implementations for now, but the technique can only make arrays, then can't currently be converted to slices or this crate's string types in const contexts. Yet. Any one of several unstable features getting stabilized would enable this, so holding off for now.

from widestring-rs.

luser avatar luser commented on June 14, 2024

There's also utf16_lit which does roughly the same thing, but doesn't have a dependency on syn, which is nice.

from widestring-rs.

starkat99 avatar starkat99 commented on June 14, 2024

Rust 1.56 stabilized mem::transmute as const, so I was able to implement the macros. There is a macro for each wide string slice type, including alias macros for WideStr/WideCStr.

Seems to work out well in unit tests. Here's example usage:

const MY_STR: &U16CStr = u16cstr!("A constant, nul-terminated UTF-16 string!");

from widestring-rs.

Related Issues (20)

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.