-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into intrinsic-die
* master: feat: Improved error message for unexpected return type (#2302) feat(stdlib): Implement `str` `as_bytes` and `into_bytes` function (#2298) chore(ci): automatically convert changelog entries to sentence case (#2325)
- Loading branch information
Showing
16 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
crates/nargo_cli/tests/execution_success/str_as_bytes/Nargo.toml
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,7 @@ | ||
[package] | ||
name = "str_as_bytes" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = "0.9.0" | ||
|
||
[dependencies] |
18 changes: 18 additions & 0 deletions
18
crates/nargo_cli/tests/execution_success/str_as_bytes/src/main.nr
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,18 @@ | ||
use dep::std; | ||
fn main() { | ||
let a = "hello"; | ||
let b = a.as_bytes(); | ||
assert(b[0]==104); | ||
assert(b[1]==101); | ||
assert(b[2]==108); | ||
assert(b[3]==108); | ||
assert(b[4]==111); | ||
assert(b.len()==5); | ||
let mut c = a.as_bytes_vec(); | ||
assert(c.get(0)==104); | ||
assert(c.get(1)==101); | ||
assert(c.get(2)==108); | ||
assert(c.get(3)==108); | ||
assert(c.get(4)==111); | ||
assert(c.len()==5); | ||
} |
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
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[package] | ||
name = "std" | ||
type = "lib" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
|
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,11 @@ | ||
use crate::collections::vec::Vec; | ||
impl<N> str<N> { | ||
/// Converts the given string into a byte array | ||
#[builtin(str_as_bytes)] | ||
fn as_bytes(_self: Self) -> [u8; N] { } | ||
|
||
/// return a byte vector of the str content | ||
fn as_bytes_vec(self: Self) -> Vec<u8> { | ||
Vec::from_slice(self.as_bytes().as_slice()) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -20,5 +20,8 @@ | |
} | ||
] | ||
} | ||
} | ||
}, | ||
"plugins": [ | ||
"sentence-case" | ||
] | ||
} |