-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. It is updated according to changes in the compiler Rust.
2. Add edition=2018. 3. Documentation is updated. 4. The code of a plug-in is rewritten and optimized. 5. Examples 'use, panic' are rewritten, the example of benchmarking is added. 6. Updating of the license according to 2019, the English version of a name of the developer is added. 7. 'Travis.yml' fix, 'Cargo.toml' description corrected.
- Loading branch information
1 parent
c0a9522
commit 52fffbb
Showing
10 changed files
with
726 additions
and
536 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
|
||
//RUN cargo bench --example bench | ||
#![feature(test)] | ||
|
||
#![feature(plugin)] | ||
#![plugin(clucstr)] | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use tests::test::Bencher; | ||
use std::ffi::CStr; | ||
|
||
extern crate test; | ||
|
||
|
||
|
||
macro_rules! unsafe_cstr { | ||
($s:expr) => { | ||
unsafe { | ||
::std::ffi::CStr::from_ptr( | ||
concat!($s, "\0") | ||
as *const str | ||
as *const [::std::os::raw::c_char] | ||
as *const ::std::os::raw::c_char | ||
) | ||
} | ||
}; | ||
} | ||
|
||
#[bench] | ||
fn cstr_plugin(b: &mut Bencher) { | ||
b.iter(|| { | ||
for _a in 0..10 { | ||
let _cstr0 = cstr!(b"test"); | ||
} | ||
}); | ||
} | ||
#[bench] | ||
fn cstr_macros(b: &mut Bencher) { | ||
b.iter(|| { | ||
for _a in 0..10 { | ||
let _cstr0 = unsafe_cstr!("test"); | ||
} | ||
}); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#![feature(plugin)] | ||
#![plugin(clucstr)] | ||
|
||
#[allow(unused_imports)] | ||
use std::ffi::CStr; | ||
|
||
//ATTENTION!!! | ||
// | ||
//For display of panic 'RLS or Rust Check' it is required to uncomment functions. | ||
|
||
fn main() { | ||
//let c_str = cstr!("cluW\0orld"); | ||
//PANIC! trailing byte detected | ||
|
||
//let c_str2 = cstr!("cluWorld\0\0"); | ||
//PANIC! trailing byte detected | ||
|
||
//let c_str3 = cstr!("\0clu", b"W\0orld"); | ||
//PANIC! trailing byte detected | ||
|
||
/*let c_str4 = cstr!( | ||
b'c', b'l', b'u', 0u8, | ||
b'W', b'o', b'r', b'l', b'd', | ||
0 | ||
);*/ | ||
//PANIC! trailing byte detected | ||
} |
This file contains 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
Oops, something went wrong.