Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clucompany/cluconcatbytes
Merges literals into a static array. Plugin for compiler.
https://github.com/clucompany/cluconcatbytes
clucompany concat concat-byte-array concat-bytes rust-library rust-plugin
Last synced: 29 days ago
JSON representation
Merges literals into a static array. Plugin for compiler.
- Host: GitHub
- URL: https://github.com/clucompany/cluconcatbytes
- Owner: clucompany
- License: apache-2.0
- Created: 2019-04-01T11:41:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-23T17:17:06.000Z (over 5 years ago)
- Last Synced: 2024-11-19T06:59:20.564Z (about 1 month ago)
- Topics: clucompany, concat, concat-byte-array, concat-bytes, rust-library, rust-plugin
- Language: Rust
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cluConcatBytes
[![Build Status](https://travis-ci.org/clucompany/cluConcatBytes.svg?branch=master)](https://travis-ci.org/clucompany/cluConcatBytes)
[![Apache licensed](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)
[![crates.io](http://meritbadge.herokuapp.com/cluConcatBytes)](https://crates.io/crates/cluConcatBytes)
[![Documentation](https://docs.rs/cluConcatBytes/badge.svg)](https://docs.rs/cluConcatBytes)Merges literals into a static array. Plugin for compiler.
# Use
1. Easy use
```rust
#![feature(plugin)]
#![plugin(cluConcatBytes)]fn main() {
let c_str = concat_bytes!("cluWorld");
//&'static [u8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(c_str, b"cluWorld");
let c_str2 = concat_bytes!("clu", b"World");
//&'static [u8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(c_str2, b"cluWorld");
let c_str3 = concat_bytes!(
b'c', b'l', b'u',
b'W', b'o', b'r', b'l', b'd'
);
//&'static [u8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(c_str3, b"cluWorld");
let c_str4 = concat_bytes!(
"clu", b'W', b'o', b'r', b'l', b"d"
);
//&'static [u8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(c_str4, b"cluWorld");
my_function(c_str);
my_function(c_str2);
my_function(c_str3);
my_function(c_str4);
}fn my_function(array: &'static [u8]) {
//'static --> it is possible not to write.
println!("array: {:?}, len: {}", array, array.len());
}
```2. Raw use
```rust
#![feature(plugin)]
#![plugin(cluConcatBytes)]fn main() {
let c_str = concat_bytes!(@"cluWorld");
//[u8; 8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(&c_str, b"cluWorld");
let c_str2 = concat_bytes!(@"cluWorld");
//[u8; 8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(&c_str2, b"cluWorld");
let c_str3 = concat_bytes!(@"clu", b"World");
//[u8; 8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(&c_str3, b"cluWorld");
my_function(c_str);
my_function(c_str2);
my_function(c_str3);
}fn my_function(array: [u8; 8]) {
//'static --> it is possible not to write.
println!("array: {:?}, len: {}", array, array.len());
}
```# License
Copyright 2019 #UlinProject Denis Kotlyarov (Денис Котляров)
Licensed under the Apache License, Version 2.0