Skip to content

Commit ce29dfc

Browse files
committed
complete advanced features
1 parent 394a3d7 commit ce29dfc

File tree

115 files changed

+2016
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2016
-60
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{k}{use}\PYG{+w}{ }\PYG{n}{std}::\PYG{n}{ops}::\PYG{n}{Add}\PYG{p}{;}
3+
4+
\PYG{k}{struct} \PYG{n+nc}{Millimeters}\PYG{p}{(}\PYG{k+kt}{u32}\PYG{p}{);}
5+
\PYG{k}{struct} \PYG{n+nc}{Meters}\PYG{p}{(}\PYG{k+kt}{u32}\PYG{p}{);}
6+
7+
\PYG{k}{impl}\PYG{+w}{ }\PYG{n}{Add}\PYG{o}{\PYGZlt{}}\PYG{n}{Meters}\PYG{o}{\PYGZgt{}}\PYG{+w}{ }\PYG{k}{for}\PYG{+w}{ }\PYG{n}{Millimeters}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
8+
\PYG{+w}{ }\PYG{k}{type} \PYG{n+nc}{Output}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{Millimeters}\PYG{p}{;}
9+
10+
\PYG{+w}{ }\PYG{k}{fn} \PYG{n+nf}{add}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{p}{,}\PYG{+w}{ }\PYG{n}{other}: \PYG{n+nc}{Meters}\PYG{p}{)}\PYG{+w}{ }\PYGZhy{}\PYGZgt{} \PYG{n+nc}{Millimeters}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
11+
\PYG{+w}{ }\PYG{n}{Millimeters}\PYG{p}{(}\PYG{n+nb+bp}{self}\PYG{p}{.}\PYG{l+m+mi}{0}\PYG{+w}{ }\PYG{o}{+}\PYG{+w}{ }\PYG{p}{(}\PYG{n}{other}\PYG{p}{.}\PYG{l+m+mi}{0}\PYG{+w}{ }\PYG{o}{*}\PYG{+w}{ }\PYG{l+m+mi}{1000}\PYG{p}{))}
12+
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
13+
\PYG{p}{\PYGZcb{}}
14+
\end{Verbatim}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{n}{quote}
3+
\end{Verbatim}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{k}{use}\PYG{+w}{ }\PYG{n}{std}::\PYG{n}{slice}\PYG{p}{;}
3+
4+
\PYG{k}{fn} \PYG{n+nf}{split\PYGZus{}at\PYGZus{}mut}\PYG{p}{(}\PYG{n}{values}: \PYG{k+kp}{\PYGZam{}}\PYG{n+nc}{mut}\PYG{+w}{ }\PYG{p}{[}\PYG{k+kt}{i32}\PYG{p}{],}\PYG{+w}{ }\PYG{n}{mid}: \PYG{k+kt}{usize}\PYG{p}{)}\PYG{+w}{ }\PYGZhy{}\PYGZgt{} \PYG{p}{(}\PYG{o}{\PYGZam{}}\PYG{k}{mut}\PYG{+w}{ }\PYG{p}{[}\PYG{k+kt}{i32}\PYG{p}{],}\PYG{+w}{ }\PYG{o}{\PYGZam{}}\PYG{k}{mut}\PYG{+w}{ }\PYG{p}{[}\PYG{k+kt}{i32}\PYG{p}{])}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
5+
\PYG{+w}{ }\PYG{k+kd}{let}\PYG{+w}{ }\PYG{n}{len}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{values}\PYG{p}{.}\PYG{n}{len}\PYG{p}{();}
6+
\PYG{+w}{ }\PYG{k+kd}{let}\PYG{+w}{ }\PYG{n}{ptr}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{values}\PYG{p}{.}\PYG{n}{as\PYGZus{}mut\PYGZus{}ptr}\PYG{p}{();}
7+
8+
\PYG{+w}{ }\PYG{n+nf+fm}{assert!}\PYG{p}{(}\PYG{n}{mid}\PYG{+w}{ }\PYG{o}{\PYGZlt{}=}\PYG{+w}{ }\PYG{n}{len}\PYG{p}{);}
9+
10+
\PYG{+w}{ }\PYG{k}{unsafe}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
11+
\PYG{+w}{ }\PYG{p}{(}
12+
\PYG{+w}{ }\PYG{n}{slice}::\PYG{n}{from\PYGZus{}raw\PYGZus{}parts\PYGZus{}mut}\PYG{p}{(}\PYG{n}{ptr}\PYG{p}{,}\PYG{+w}{ }\PYG{n}{mid}\PYG{p}{),}
13+
\PYG{+w}{ }\PYG{n}{slice}::\PYG{n}{from\PYGZus{}raw\PYGZus{}parts\PYGZus{}mut}\PYG{p}{(}\PYG{n}{ptr}\PYG{p}{.}\PYG{n}{add}\PYG{p}{(}\PYG{n}{mid}\PYG{p}{),}\PYG{+w}{ }\PYG{n}{len}\PYG{+w}{ }\PYG{o}{\PYGZhy{}}\PYG{+w}{ }\PYG{n}{mid}\PYG{p}{),}
14+
\PYG{+w}{ }\PYG{p}{)}
15+
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
16+
\PYG{p}{\PYGZcb{}}
17+
\end{Verbatim}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{l+s}{\PYGZdq{}/\PYGZdq{}}
3+
\end{Verbatim}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{o}{\PYGZam{}}\PYG{n}{T}
3+
\end{Verbatim}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{n+nf+fm}{macro\PYGZus{}rules!}
3+
\end{Verbatim}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{n+nv}{\PYGZdl{}x}
3+
\end{Verbatim}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{k+kd}{let}\PYG{+w}{ }\PYG{k}{mut}\PYG{+w}{ }\PYG{n}{num}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{l+m+mi}{5}\PYG{p}{;}
3+
\PYG{c+c1}{// Create raw pointers in safe code; we just can’t dereference raw pointers outside an unsafe block}
4+
\PYG{k+kd}{let}\PYG{+w}{ }\PYG{n}{r1}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{o}{\PYGZam{}}\PYG{n}{num}\PYG{+w}{ }\PYG{k}{as}\PYG{+w}{ }\PYG{o}{*}\PYG{k}{const}\PYG{+w}{ }\PYG{k+kt}{i32}\PYG{p}{;}
5+
\PYG{k+kd}{let}\PYG{+w}{ }\PYG{n}{r2}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{o}{\PYGZam{}}\PYG{k}{mut}\PYG{+w}{ }\PYG{n}{num}\PYG{+w}{ }\PYG{k}{as}\PYG{+w}{ }\PYG{o}{*}\PYG{k}{mut}\PYG{+w}{ }\PYG{k+kt}{i32}\PYG{p}{;}
6+
\PYG{k}{unsafe}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
7+
\PYG{+w}{ }\PYG{n+nf+fm}{println!}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}r1 is: \PYGZob{}\PYGZcb{}\PYGZdq{}}\PYG{p}{,}\PYG{+w}{ }\PYG{o}{*}\PYG{n}{r1}\PYG{p}{);}
8+
\PYG{+w}{ }\PYG{n+nf+fm}{println!}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}r2 is: \PYGZob{}\PYGZcb{}\PYGZdq{}}\PYG{p}{,}\PYG{+w}{ }\PYG{o}{*}\PYG{n}{r2}\PYG{p}{);}
9+
\PYG{p}{\PYGZcb{}}
10+
\end{Verbatim}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
2+
\PYG{+w}{ }\PYG{c+c1}{// \PYGZhy{}\PYGZhy{}snip\PYGZhy{}\PYGZhy{}}
3+
4+
\PYG{+w}{ }\PYG{n}{ident}: \PYG{n+nc}{Ident}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
5+
\PYG{+w}{ }\PYG{n}{ident}: \PYG{l+s}{\PYGZdq{}Pancakes\PYGZdq{}}\PYG{p}{,}
6+
\PYG{+w}{ }\PYG{n}{span}: \PYGZsh{}\PYG{l+m+mi}{0}\PYG{+w}{ }\PYG{n}{bytes}\PYG{p}{(}\PYG{l+m+mi}{95}\PYG{o}{..}\PYG{l+m+mi}{103}\PYG{p}{)}
7+
\PYG{+w}{ }\PYG{p}{\PYGZcb{},}
8+
\PYG{+w}{ }\PYG{n}{data}: \PYG{n+nc}{Struct}\PYG{p}{(}
9+
\PYG{+w}{ }\PYG{n}{DataStruct}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
10+
\PYG{+w}{ }\PYG{n}{struct\PYGZus{}token}: \PYG{n+nc}{Struct}\PYG{p}{,}
11+
\PYG{+w}{ }\PYG{n}{fields}: \PYG{n+nc}{Unit}\PYG{p}{,}
12+
\PYG{+w}{ }\PYG{n}{semi\PYGZus{}token}: \PYG{n+nb}{Some}\PYG{p}{(}
13+
\PYG{+w}{ }\PYG{n}{Semi}
14+
\PYG{+w}{ }\PYG{p}{)}
15+
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
16+
\PYG{+w}{ }\PYG{p}{)}
17+
\PYG{p}{\PYGZcb{}}
18+
\end{Verbatim}

0 commit comments

Comments
 (0)