Comments (4)
Yeah I think a doc(hidden)
const fn is better than having a public-but-hidden field, you have to very explicitly find and call that API.
from data-encoding.
Thanks for the bug report! I didn't know it was possible to have doc(hidden)
on fields. The field needs to be public for data-encoding-macro
. The type was already doc(hidden)
and is named InternalEncoding
which are good indicators that users should not touch it. But making the field itself doc(hidden)
is also another good hint. Sending #76 to fix that.
Note that eventually, when const fn
support is powerful enough, data-encoding-macro
would disappear and the field could become private again. Actually, it's probably also a good idea to make the field private and only expose an unsafe const fn
, but that would be a breaking change because data-encoding-macro
does not depend on an exact version. Adding to the wish list in #72.
from data-encoding.
@ia0 it may also be worth renaming the field something suitably scary, because it is relatively easy to not notice that x.0
is forbidden: it shows up in error messages and stuff.
I'd also recommend against using doc(hidden) fields when there are unsafe invariants; if possible it would be better to expose a const unsafe fn
constructor and call it from the macro.
from data-encoding.
Yes, I think the const unsafe fn
is the best option. Actually, I misremembered, I already have and use a const fn
so I can make the field private (that might have been an oversight, or maybe deliberate to hide a breaking change over a few years). Making the const fn
unsafe would still be a breaking change though, but I could also hide it under a few years (i.e. assuming users don't use a data-encoding
version older by a year than the data-encoding-macro
version).
from data-encoding.
Related Issues (20)
- no-std support for macro crate
- Macros Won't Build in no_std HOT 4
- (std -> core)::fmt::Display for DecodeError and DecodeKind HOT 2
- feature `std` leaking when using macro in no_std env HOT 7
- Missing a new line and decode error HOT 2
- Rust 2021 edition is a major, not a "patch" change HOT 6
- Removing dependency on syn HOT 7
- Make `{encode,decode}_len` const fns? HOT 4
- Encode into an "impl std::fmt::Write" and/or "impl std::io::Write" HOT 5
- Breaking change wish list
- Use doc_auto_cfg once stable HOT 2
- Use as_chunks family of functions once stable
- Deny warnings in rustdoc
- Partial encoding with padding HOT 3
- Question about Specification HOT 6
- Release 2.5.0
- SIMD optimization HOT 4
- `Encoding::encode_mut` is very code-size heavy HOT 15
- feature request - base58 d/encoding HOT 2
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 data-encoding.