-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no_std support #336
Comments
Honestly I'm not sure how far Chrono is from supporting no_std when the default features are turned off. I think some people might already be using it semi-successfully? Code that people would like to work, but does not, would be welcome. For example, this seems to work: #![no_std]
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
use chrono::TimeZone;
let _ = chrono::Utc.ymd(1999, 1,1).and_hms(1, 2, 3);
}
} |
My understanding is that testing |
that makes sense, this also works, though: # Cargo.toml
[package]
name = "nostd"
version = "0.1.0"
authors = ["Brandon W Maister <quodlibetor@gmail.com>"]
edition = "2018"
[dependencies]
chrono = { version = "0.4", default-features = false } // src/lib.rs
#![no_std]
use chrono::TimeZone;
pub fn dt() -> chrono::DateTime<chrono::Utc> {
chrono::Utc.ymd(1999, 1,1).and_hms(1, 2, 3)
} $ cargo build
Compiling nostd v0.1.0 (/Users/bwm/github/chrono/examples/nostd)
Finished dev [unoptimized + debuginfo] target(s) in 0.14s |
I'm pretty sure that chrono doesn't work well in no-std environments, but I don't know what people would expect to work, or how folks would like to be able to interact with it. Examples of code that doesn't work that anyone would expect to would be great. |
I haven't explored too deeply on what does or does not work, but the code I hope would be possible to make work is: https://github.com/alex/rust-asn1/blob/0fe97f6cdddc7ba718e12b3f0880dc2f924915b5/src/parser.rs#L281-L324 |
Do you have an example of the exact error that you're getting? Most of the code in there seems like it should either already work or be trivial to make work. edit: oh no I said should be trivial. |
I don't, it's entirely possible this works fine! I generally assume crates aren't |
haha lmk how it goes and I'll document it 😛 |
Considering my crate makes heavy use of chrono, I'll take a shot at this. Atm I've polyfilled chrono, but that shouldn't be necessary. |
thanks! |
Alright, I have a working branch now. The only remaining problem is that I needed to get rid of all the dev-dependencies |
This adds a new `std` feature to chrono that is enabled by default. By deactivating this feature via `default-features = false` you can now use chrono in applications that don't use the standard library. The `serde` feature is supported as well. Resolves chronotope#336
mentioned in 195, we need a good story around no_std/alloc support.
The parts of this that jump right to mind:
Write
The text was updated successfully, but these errors were encountered: