Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gustav Hansson
e7020e_2020
Commits
97f91516
Commit
97f91516
authored
5 years ago
by
Gustav Hansson
Browse files
Options
Downloads
Patches
Plain Diff
bare3 0-2
parent
6c41109f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/bare3.rs
+21
-11
21 additions, 11 deletions
examples/bare3.rs
with
21 additions
and
11 deletions
examples/bare3.rs
+
21
−
11
View file @
97f91516
...
...
@@ -18,25 +18,25 @@ use cortex_m_semihosting::{hprint, hprintln};
#[entry]
fn
main
()
->
!
{
hprintln!
(
"bare3"
)
.unwrap
();
let
s
=
"ABCD"
;
let
bs
=
s
.as_bytes
();
let
s
:
&
str
=
"ABCD"
;
let
bs
:
&
[
u8
]
=
s
.as_bytes
();
hprintln!
(
"s = {}"
,
s
)
.unwrap
();
hprintln!
(
"bs = {:?}"
,
bs
)
.unwrap
();
hprintln!
(
"iterate over slice"
)
.unwrap
();
for
c
in
bs
{
hprint!
(
"{},"
,
c
)
.unwrap
();
hprint!
(
"{},"
,
c
as
&
u8
)
.unwrap
();
}
hprintln!
(
"iterate iterate using (raw) indexing"
)
.unwrap
();
for
i
in
0
..
s
.len
()
{
for
i
in
0
usize
..
s
.len
()
{
hprintln!
(
"{},"
,
bs
[
i
])
.unwrap
();
}
hprintln!
(
""
)
.unwrap
();
let
a
=
[
65u8
;
4
];
let
a
:
[
u8
;
4
]
=
[
65u8
;
4
];
// let mut a = [0u8; 4];
hprintln!
(
""
)
.unwrap
();
...
...
@@ -54,27 +54,37 @@ fn main() -> ! {
//
// 1. What is the output in the `openocd` (Adapter Output) console?
//
// ** your answer here **
// s = ABCD
// bs = [65, 66, 67, 68]
// iterate over slice
// 65,66,67,68,iterate iterate using (raw) indexing
// 65,
// 66,
// 67,
// 68,
// a = AAAA
//
// What is the type of `s`?
//
//
** your answer here **
//
&str
//
// What is the type of `bs`?
//
//
** your answer here **
//
&[u8]
//
// What is the type of `c`?
//
//
** your answer here **
//
&u8
//
// What is the type of `a`?
//
//
** your answer here **
//
[u8; 4]
//
// What is the type of `i`?
//
//
** your answer here **
//
usize
//
// Commit your answers (bare3_1)
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment