Comments (3)
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.
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.
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)
- Won't build for 1.26.0 HOT 1
- 0.4.1 fails to build on Debian (rustc 1.34.2) HOT 2
- `
- UCStr::from_ptr_with_nul & inconsistent documentation + behaviors around nulls HOT 1
- Add a way to create U32/U16 string from number HOT 1
- Add `Display` implementation HOT 2
- Remove implementation based on generics
- panic in version 0.5 when no problem in 0.4 HOT 2
- Create an empty `U16CString` HOT 1
- impl `TryFrom` for fallible string conversions HOT 2
- Macros for c-style strings should check for interior nuls
- Feature request: insert / insert_str HOT 1
- Provide lines iterator
- Provide a `Pattern`-like API
- Provide a `include_str` alternative
- No conversion from Utf32String to Vec<char>
- WideCString.to_wide_string contains NULL value HOT 1
- Why is WideCString::from_str_unchecked unsafe? HOT 1
- library uses u16 rather than wchar_t HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from widestring-rs.