This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
new literacy::{Read, Write} traits to handle std/no_std (alternative) #127
Closed
Closed
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f693c4b
new literacy::{Read, Write} traits to handle std/no_std
RCasatta 41e04db
use associated type in literacy Read/Write trait
RCasatta 4291b4b
add default impl for vec and slice, remove blanket impl
RCasatta 73c4aad
upgrade CI
RCasatta 62855e6
defaults to core2 if both std and core2 features enabled, fixes
RCasatta 8bf2f9e
Docs for literacy module and restore enforcing docs
RCasatta 12580fd
use macros to impl literacy::Write
sgeisler 9e49b27
test with serde feature
RCasatta a37f2be
Add take to literacy::Read trait
RCasatta a8eb19c
rexport literacy::Error according to the activated feature
RCasatta 1f500f1
use literacy::Error also for engines
RCasatta 6b7b28f
add Read trait bound to Take
RCasatta c6d4ca4
remove Take
RCasatta 38bb903
Add literacy:Error with inexpensive ErrorKind and inner error for int…
RCasatta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#!/bin/sh -ex | ||
#!/bin/bash -ex | ||
|
||
FEATURES="serde serde-std" | ||
# Combination of features to test, should be every features combination but std and core2 together | ||
# note std has a comma in the end so that following regex avoid matching serde-std | ||
FEATURES=("" "std," "use-core2" "std,serde-std" "use-core2,serde-std") | ||
|
||
# Use toolchain if explicitly specified | ||
if [ -n "$TOOLCHAIN" ] | ||
then | ||
if [[ -n "$TOOLCHAIN" ]]; then | ||
alias cargo="cargo +$TOOLCHAIN" | ||
fi | ||
|
||
|
@@ -18,35 +19,27 @@ export CARGO_TERM_VERBOSE=true | |
cargo build --all | ||
cargo test --all | ||
|
||
if [ "$DO_FEATURE_MATRIX" = true ]; then | ||
cargo build --all --no-default-features | ||
cargo test --all --no-default-features | ||
|
||
# All features | ||
cargo build --all --no-default-features --features="$FEATURES" | ||
cargo test --all --features="$FEATURES" | ||
# Single features | ||
for feature in ${FEATURES} | ||
do | ||
cargo build --all --no-default-features --features="$feature" | ||
cargo test --all --features="$feature" | ||
done | ||
|
||
# Other combos | ||
cargo test --all --features="serde-std" | ||
if [[ "$DO_FEATURE_MATRIX" = true ]]; then | ||
for feature in "${FEATURES[@]}" | ||
do | ||
# On rust 1.29.0 we are only testing with std lib | ||
if [[ "$ON_1_29_0" = false || ${feature} =~ "std," ]]; then | ||
echo "--------------$feature----------------" | ||
cargo build --no-default-features --features="$feature" | ||
if [[ ${feature} =~ "std," ]] ; then | ||
cargo test --no-default-features --features="$feature" | ||
fi | ||
cargo doc --no-default-features --features="$feature" | ||
fi | ||
done | ||
fi | ||
|
||
if [ "$DO_SCHEMARS_TESTS" = true ]; then | ||
if [[ "$ON_1_29_0" = false ]]; then | ||
(cd extended_tests/schemars && cargo test) | ||
fi | ||
|
||
# Docs | ||
if [ "$DO_DOCS" = true ]; then | ||
cargo doc --all --features="$FEATURES" | ||
fi | ||
|
||
# Webassembly stuff | ||
if [ "$DO_WASM" = true ]; then | ||
if [[ "$DO_WASM" = true ]]; then | ||
clang --version && | ||
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack && | ||
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml && | ||
|
@@ -55,20 +48,19 @@ if [ "$DO_WASM" = true ]; then | |
fi | ||
|
||
# Address Sanitizer | ||
if [ "$DO_ASAN" = true ]; then | ||
if [[ "$DO_ASAN" = true ]]; then | ||
cargo clean | ||
CC='clang -fsanitize=address -fno-omit-frame-pointer' \ | ||
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \ | ||
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ | ||
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu | ||
cargo test --lib --all -Zbuild-std --target x86_64-unknown-linux-gnu | ||
cargo clean | ||
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ | ||
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ | ||
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be |
||
cargo test --lib --all -Zbuild-std --target x86_64-unknown-linux-gnu | ||
fi | ||
|
||
# Bench | ||
if [ "$DO_BENCH" = true ]; then | ||
if [[ "$DO_BENCH" = true ]]; then | ||
cargo bench --all --features="unstable" | ||
fi | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
#![deny(non_camel_case_types)] | ||
#![deny(non_snake_case)] | ||
#![deny(unused_mut)] | ||
#![deny(missing_docs)] | ||
//#![deny(missing_docs)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope you didn't intend to land this :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed, and added doc where missing in 8bf2f9e |
||
|
||
// In general, rust is absolutely horrid at supporting users doing things like, | ||
// for example, compiling Rust code for real environments. Disable useless lints | ||
|
@@ -51,9 +51,12 @@ pub mod _export { | |
|
||
#[cfg(feature = "schemars")] extern crate schemars; | ||
|
||
#[cfg(all(not(feature = "use-core2"), not(feature = "std")))] | ||
extern crate alloc; | ||
|
||
#[macro_use] mod util; | ||
#[macro_use] pub mod serde_macros; | ||
#[cfg(any(test, feature = "std"))] mod std_impls; | ||
mod impls; | ||
pub mod error; | ||
pub mod hex; | ||
pub mod hash160; | ||
|
@@ -66,6 +69,7 @@ pub mod sha256t; | |
pub mod siphash24; | ||
pub mod sha512; | ||
pub mod cmp; | ||
pub mod literacy; | ||
|
||
use core::{borrow, fmt, hash, ops}; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we only test with
std
and just build the rest of the time?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because tests have std enabled
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]