Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Use macro sizedbytes to remove redundant decl of byte string length #2

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demos/hello rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ authors = ["Steve Klabnik <[email protected]>"]
crate-type = ["staticlib"]

[dependencies]
bytestool = "0.2.0"
sizedbytes = "0.1.0"

[profile.release]
panic = "abort"
14 changes: 10 additions & 4 deletions demos/hello rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#![feature(lang_items)]
#![no_std]

#![feature(plugin)]
#![plugin(bytestool)]
#[macro_use(sized_bytes)]

extern crate sizedbytes;
use sizedbytes::SizedBytes;

#[no_mangle]
pub extern fn kmain() -> ! {
let char_bytes = b"Hello World!";
const MESG : SizedBytes = sized_bytes!(b"Hello World");

let color_byte = 0x1f;


let mut message = [color_byte; 24];
for (i, char_byte) in char_bytes.into_iter().enumerate() {
let mut message = [color_byte; MESG.size * 2 ];
for (i, char_byte) in MESG.bytes.into_iter().enumerate() {
message[i * 2] = *char_byte;
}

Expand Down