on master help sign in
c3509cfiko
nock/src/cue.rs+1−1
@@ -47,7 +47,7 @@ fn cue_reader(
47 } else {
47 } else {
48 let p = cue_reader(reader, offset, refs);
48 let p = cue_reader(reader, offset, refs);
49 let q = cue_reader(reader, offset, refs);
49 let q = cue_reader(reader, offset, refs);
50− let x = cell(p, q);
50+ let x = cell(&p, &q);
51 refs.insert(original_offset, x.clone());
51 refs.insert(original_offset, x.clone());
52 x
52 x
53 }
53 }
nock/src/interpreter.rs+47−35
@@ -47,8 +47,8 @@ pub fn generate_interpreter_context() -> InterpreterContext {
47 let two = Rc::new(Noun::Atom(big_uints.two.clone()));
47 let two = Rc::new(Noun::Atom(big_uints.two.clone()));
48 let three = Rc::new(Noun::Atom(big_uints.three.clone()));
48 let three = Rc::new(Noun::Atom(big_uints.three.clone()));
49 let four = Rc::new(Noun::Atom(big_uints.four.clone()));
49 let four = Rc::new(Noun::Atom(big_uints.four.clone()));
50− let sig_one = cell(sig.clone(), one.clone());
50+ let sig_one = cell(&sig, &one);
51− let two_three = cell(two.clone(), three.clone());
51+ let two_three = cell(&two, &three);
52 InterpreterContext {
52 InterpreterContext {
53 jets,
53 jets,
54 double_jets,
54 double_jets,
@@ -67,21 +67,21 @@ pub fn generate_interpreter_context() -> InterpreterContext {
67 }
67 }
68}
68}
69
69
70−fn wut(ctx: &InterpreterContext, noun: Rc<Noun>) -> Rc<Noun> {
70+fn wut(ctx: &InterpreterContext, noun: &Noun) -> Rc<Noun> {
71− match *noun {
71+ match noun {
72 Noun::Cell { .. } => ctx.nouns.sig.clone(),
72 Noun::Cell { .. } => ctx.nouns.sig.clone(),
73 Noun::Atom(_) => ctx.nouns.one.clone(),
73 Noun::Atom(_) => ctx.nouns.one.clone(),
74 }
74 }
75}
75}
76
76
77−fn lus(noun: Rc<Noun>) -> Option<Noun> {
77+fn lus(noun: &Noun) -> Option<Noun> {
78 match (*noun).clone() {
78 match (*noun).clone() {
79 Noun::Cell { .. } => None,
79 Noun::Cell { .. } => None,
80 Noun::Atom(atm) => Some(Noun::Atom(atm + 1u32)),
80 Noun::Atom(atm) => Some(Noun::Atom(atm + 1u32)),
81 }
81 }
82}
82}
83
83
84−fn tis(ctx: &InterpreterContext, lhs: Rc<Noun>, rhs: Rc<Noun>) -> Rc<Noun> {
84+fn tis(ctx: &InterpreterContext, lhs: &Noun, rhs: &Noun) -> Rc<Noun> {
85 if lhs == rhs {
85 if lhs == rhs {
86 ctx.nouns.sig.clone()
86 ctx.nouns.sig.clone()
87 } else {
87 } else {
@@ -89,14 +89,14 @@ fn tis(ctx: &InterpreterContext, lhs: Rc<Noun>, rhs: Rc<Noun>) -> Rc<Noun> {
89 }
89 }
90}
90}
91
91
92−fn fas(ctx: &InterpreterContext, addr: Atom, noun: &Noun) -> Option<Rc<Noun>> {
92+fn fas(ctx: &InterpreterContext, addr: &Atom, noun: &Noun) -> Option<Rc<Noun>> {
93 let mut addr_iter = addr.iter_u32_digits();
93 let mut addr_iter = addr.iter_u32_digits();
94
94
95 match addr_iter.len() {
95 match addr_iter.len() {
96 0 => None,
96 0 => None,
97 1 => Some(fas_u32(addr_iter.next()?, noun)?),
97 1 => Some(fas_u32(addr_iter.next()?, noun)?),
98 _ => {
98 _ => {
99− let rest = fas(ctx, &addr >> 1, noun)?;
99+ let rest = fas(ctx, &(addr >> 1u8), noun)?;
100 Some(fas_u32(
100 Some(fas_u32(
101 if (addr & &ctx.big_uints.one) == ctx.big_uints.one {
101 if (addr & &ctx.big_uints.one) == ctx.big_uints.one {
102 3
102 3
@@ -119,7 +119,7 @@ fn fas_u32(addr: u32, noun: &Noun) -> Option<Rc<Noun>> {
119 2 => Some(p.clone()),
119 2 => Some(p.clone()),
120 3 => Some(q.clone()),
120 3 => Some(q.clone()),
121 _ => {
121 _ => {
122− let rest = fas_u32(n >> 1, &naked_cell(p.clone(), q.clone()))?;
122+ let rest = fas_u32(n >> 1, &naked_cell(&p, &q))?;
123 fas_u32(if (n & 1) == 1 { 3 } else { 2 }, &rest)
123 fas_u32(if (n & 1) == 1 { 3 } else { 2 }, &rest)
124 }
124 }
125 },
125 },
@@ -134,9 +134,11 @@ fn hax_u32(addr: u32, new_value: Rc<Noun>, target: Rc<Noun>) -> Option<Rc<Noun>>
134 _ => hax_u32(
134 _ => hax_u32(
135 addr >> 1,
135 addr >> 1,
136 if (addr & 1) == 1 {
136 if (addr & 1) == 1 {
137− cell(fas_u32(addr - 1, &target)?, new_value)
137+ let foo = fas_u32(addr - 1, &target)?;
138+ cell(&foo, &new_value)
138 } else {
139 } else {
139− cell(new_value, fas_u32(addr + 1, &target)?)
140+ let foo = fas_u32(addr + 1, &target)?;
141+ cell(&new_value, &foo)
140 },
142 },
141 target,
143 target,
142 ),
144 ),
@@ -158,9 +160,11 @@ fn hax(
158 ctx,
160 ctx,
159 &addr >> 1u32,
161 &addr >> 1u32,
160 if (&addr & &ctx.big_uints.one) == ctx.big_uints.one {
162 if (&addr & &ctx.big_uints.one) == ctx.big_uints.one {
161− cell(fas(ctx, addr - &ctx.big_uints.one, &target)?, new_value)
163+ let foo = fas(ctx, &(addr - &ctx.big_uints.one), &target)?;
164+ cell(&foo, &new_value)
162 } else {
165 } else {
163− cell(new_value, fas(ctx, addr + &ctx.big_uints.one, &target)?)
166+ let foo = fas(ctx, &(addr + &ctx.big_uints.one), &target)?;
167+ cell(&new_value, &foo)
164 },
168 },
165 target,
169 target,
166 ),
170 ),
@@ -171,7 +175,7 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
171 match op {
175 match op {
172 0 => {
176 0 => {
173 let b = formula.as_atom()?.clone();
177 let b = formula.as_atom()?.clone();
174− fas(ctx, b, subj)
178+ fas(ctx, &b, subj)
175 }
179 }
176 1 => Some(formula),
180 1 => Some(formula),
177 2 => {
181 2 => {
@@ -181,7 +185,7 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
181 Noun::Cell { p, q, .. }
185 Noun::Cell { p, q, .. }
182 if *p == Noun::SIG
186 if *p == Noun::SIG
183 && q == ctx.nouns.two
187 && q == ctx.nouns.two
184− && b == cell(Rc::new(Noun::SIG), ctx.nouns.one.clone()) =>
188+ && b == cell(&Noun::SIG, &ctx.nouns.one) =>
185 {
189 {
186 // This means we are about the evaluate a gate at the head of the current subject.
190 // This means we are about the evaluate a gate at the head of the current subject.
187 let (hash, sample) = subj.hash_gate();
191 let (hash, sample) = subj.hash_gate();
@@ -208,12 +212,19 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
208 }
212 }
209 }
213 }
210 }
214 }
215+ 3 => {
216+ let foo = tar(ctx, subj, &formula)?;
211− 3 => Some(wut(ctx, tar(ctx, subj, &formula)?)),
217+ Some(wut(ctx, &foo))
218+ }
219+ 4 => {
220+ let foo = tar(ctx, subj, &formula)?;
212− 4 => Some(Rc::new(lus(tar(ctx, subj, &formula)?)?)),
221+ Some(Rc::new(lus(&foo)?))
222+ }
213 5 => {
223 5 => {
214 let (b, c) = formula.as_cell()?;
224 let (b, c) = formula.as_cell()?;
215 let foo = tar(ctx, &subj, &b)?;
225 let foo = tar(ctx, &subj, &b)?;
216− Some(tis(ctx, foo, tar(ctx, subj, &c)?))
226+ let bar = tar(ctx, subj, &c)?;
227+ Some(tis(ctx, &foo, &bar))
217 }
228 }
218 6 => {
229 6 => {
219 let (b, c) = formula.as_cell()?;
230 let (b, c) = formula.as_cell()?;
@@ -221,13 +232,13 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
221
232
222 let foo = tar_u32(
233 let foo = tar_u32(
223 ctx,
234 ctx,
224− &cell(c, d),
235+ &cell(&c, &d),
225 0,
236 0,
226 tar_u32(
237 tar_u32(
227 ctx,
238 ctx,
228 &ctx.nouns.two_three,
239 &ctx.nouns.two_three,
229 0,
240 0,
230− tar_u32(ctx, subj, 4, cell(ctx.nouns.four.clone(), b))?,
241+ tar_u32(ctx, subj, 4, cell(&ctx.nouns.four, &b))?,
231 )?,
242 )?,
232 )?;
243 )?;
233
244
@@ -240,7 +251,8 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
240 }
251 }
241 8 => {
252 8 => {
242 let (b, c) = formula.as_cell()?;
253 let (b, c) = formula.as_cell()?;
243− tar(ctx, &cell(tar(ctx, &subj, &b)?, Rc::new(subj.clone())), &c)
254+ let foo = tar(ctx, &subj, &b)?;
255+ tar(ctx, &cell(&foo, subj), &c)
244 }
256 }
245 9 => {
257 9 => {
246 let (b, c) = formula.as_cell()?;
258 let (b, c) = formula.as_cell()?;
@@ -249,7 +261,7 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
249 ctx,
261 ctx,
250 &foo,
262 &foo,
251 2,
263 2,
252− cell(ctx.nouns.sig_one.clone(), cell(ctx.nouns.sig.clone(), b)),
264+ cell(&ctx.nouns.sig_one, &cell(&ctx.nouns.sig, &b)),
253 )
265 )
254 }
266 }
255 10 => {
267 10 => {
@@ -264,12 +276,11 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
264 // println!("{b}");
276 // println!("{b}");
265 match (*b).clone() {
277 match (*b).clone() {
266 Noun::Atom(_) => tar(ctx, subj, &d),
278 Noun::Atom(_) => tar(ctx, subj, &d),
267− Noun::Cell { q: c, .. } => tar_u32(
279+ Noun::Cell { q: c, .. } => {
268− ctx,
280+ let foo = tar(ctx, subj, &c)?;
269− &cell(tar(ctx, subj, &c)?, tar(ctx, subj, &d)?),
281+ let bar = tar(ctx, subj, &d)?;
270− 0,
271− ctx.nouns.three.clone(),
282+ tar_u32(ctx, &cell(&foo, &bar), 0, ctx.nouns.three.clone())
272− ),
283+ }
273 }
284 }
274 }
285 }
275 _ => None,
286 _ => None,
@@ -279,7 +290,11 @@ fn tar_u32(ctx: &InterpreterContext, subj: &Noun, op: u32, formula: Rc<Noun>) ->
279pub fn tar(ctx: &InterpreterContext, subj: &Noun, formula: &Noun) -> Option<Rc<Noun>> {
290pub fn tar(ctx: &InterpreterContext, subj: &Noun, formula: &Noun) -> Option<Rc<Noun>> {
280 let (op, formula) = formula.as_cell()?;
291 let (op, formula) = formula.as_cell()?;
281 match *op {
292 match *op {
293+ Noun::Cell { .. } => {
294+ let foo = tar(ctx, subj, &op)?;
282− Noun::Cell { .. } => Some(cell(tar(ctx, subj, &op)?, tar(ctx, subj, &formula)?)),
295+ let bar = tar(ctx, subj, &formula)?;
296+ Some(cell(&foo, &bar))
297+ }
283 Noun::Atom(ref op) => {
298 Noun::Atom(ref op) => {
284 let mut op_iter = op.iter_u32_digits();
299 let mut op_iter = op.iter_u32_digits();
285 let op = match op_iter.len() {
300 let op = match op_iter.len() {
@@ -298,11 +313,8 @@ pub fn eval_gate(ctx: &InterpreterContext, gate: Rc<Noun>) -> Option<Rc<Noun>> {
298 ctx,
313 ctx,
299 &gate,
314 &gate,
300 &cell(
315 &cell(
301− Rc::new(Noun::Atom(BigUint::new(vec![9]))),
316+ &Noun::Atom(BigUint::new(vec![9])),
302− cell(
303− ctx.nouns.two.clone(),
304− cell(ctx.nouns.sig.clone(), ctx.nouns.one.clone()),
317+ &cell(&ctx.nouns.two, &cell(&ctx.nouns.sig, &ctx.nouns.one)),
305− ),
306 ),
318 ),
307 )
319 )
308}
320}
@@ -311,5 +323,5 @@ pub fn slam(ctx: &InterpreterContext, gate: Rc<Noun>, sample: Rc<Noun>) -> Optio
311 let (battery, payload) = gate.as_cell()?;
323 let (battery, payload) = gate.as_cell()?;
312 let (_sample, context) = payload.as_cell()?;
324 let (_sample, context) = payload.as_cell()?;
313
325
314− eval_gate(ctx, cell(battery, cell(sample, context)))
326+ eval_gate(ctx, cell(&battery, &cell(&sample, &context)))
315}
327}
nock/src/jets.rs+17−11
@@ -136,7 +136,7 @@ static BINARY_ATOM_PAIR: fn(Rc<Noun>, fn(&Atom, &Atom) -> (Atom, Atom)) -> Optio
136 let (p, q) = n.as_cell()?;
136 let (p, q) = n.as_cell()?;
137
137
138 let (a, b) = f(p.as_atom()?, q.as_atom()?);
138 let (a, b) = f(p.as_atom()?, q.as_atom()?);
139− Some(cell(Rc::new(Noun::Atom(a)), Rc::new(Noun::Atom(b))))
139+ Some(cell(&Noun::Atom(a), &Noun::Atom(b)))
140 };
140 };
141
141
142static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
142static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
@@ -286,7 +286,7 @@ static FIND: Jet = |ctx, n| {
286static FLOP: Jet = |ctx, n| {
286static FLOP: Jet = |ctx, n| {
287 Some(
287 Some(
288 n.list_iter()
288 n.list_iter()
289− .fold(ctx.nouns.sig.clone(), |tail, head| cell(head, tail)),
289+ .fold(ctx.nouns.sig.clone(), |tail, head| cell(&head, &tail)),
290 )
290 )
291};
291};
292
292
@@ -317,7 +317,7 @@ static INTO: Jet = |_ctx, n| {
317 let mut b_iter = b.as_atom()?.iter_u32_digits();
317 let mut b_iter = b.as_atom()?.iter_u32_digits();
318
318
319 match b_iter.len() {
319 match b_iter.len() {
320− 0 => Some(cell(c, a)),
320+ 0 => Some(cell(&c, &a)),
321 1 => {
321 1 => {
322 let l = a.list_iter();
322 let l = a.list_iter();
323 let b = b_iter.next().unwrap() as usize;
323 let b = b_iter.next().unwrap() as usize;
@@ -407,7 +407,10 @@ static REEL: Jet = |ctx, n| {
407
407
408 list.list_iter().collect::<Vec<_>>().iter().rfold(
408 list.list_iter().collect::<Vec<_>>().iter().rfold(
409 Some(gate.clone().gate_sample()?.as_cell()?.1),
409 Some(gate.clone().gate_sample()?.as_cell()?.1),
410+ |acc, next| {
411+ let acc = acc?;
410− |acc, next| slam(ctx, gate.clone(), cell(next.clone(), acc?)),
412+ slam(ctx, gate.clone(), cell(&next, &acc))
413+ },
411 )
414 )
412};
415};
413
416
@@ -416,7 +419,10 @@ static ROLL: Jet = |ctx, n| {
416
419
417 list.list_iter().fold(
420 list.list_iter().fold(
418 Some(gate.clone().gate_sample()?.as_cell()?.1),
421 Some(gate.clone().gate_sample()?.as_cell()?.1),
422+ |acc, next| {
423+ let acc = acc?;
419− |acc, next| slam(ctx, gate.clone(), cell(next.clone(), acc?)),
424+ slam(ctx, gate.clone(), cell(&next, &acc))
425+ },
420 )
426 )
421};
427};
422
428
@@ -442,8 +448,8 @@ static SKID: Jet = |ctx, n| {
442 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
448 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
443
449
444 Some(cell(
450 Some(cell(
445− Noun::list_refs(ys.iter().map(|(_, x)| x).cloned()),
451+ &Noun::list_refs(ys.iter().map(|(_, x)| x.clone())),
446− Noun::list_refs(ns.iter().map(|(_, x)| x).cloned()),
452+ &Noun::list_refs(ns.iter().map(|(_, x)| x.clone())),
447 ))
453 ))
448};
454};
449
455
@@ -550,12 +556,12 @@ static SPIN: Jet = |ctx, n| {
550 let mut res = Vec::new();
556 let mut res = Vec::new();
551
557
552 for n in list.list_iter() {
558 for n in list.list_iter() {
553− let (el, new_acc) = slam(ctx, gate.clone(), cell(n, acc))?.as_cell()?;
559+ let (el, new_acc) = slam(ctx, gate.clone(), cell(&n, &acc))?.as_cell()?;
554 acc = new_acc;
560 acc = new_acc;
555 res.push(el);
561 res.push(el);
556 }
562 }
557
563
558− Some(cell(Noun::list_refs(res.iter().cloned()), acc))
564+ Some(cell(&Noun::list_refs(res.iter().cloned()), &acc))
559};
565};
560
566
561static SPUN: Jet = |ctx, n| {
567static SPUN: Jet = |ctx, n| {
@@ -565,12 +571,12 @@ static SPUN: Jet = |ctx, n| {
565 let mut acc = gate.clone().gate_sample()?.as_cell()?.1;
571 let mut acc = gate.clone().gate_sample()?.as_cell()?.1;
566
572
567 for n in list.list_iter() {
573 for n in list.list_iter() {
568− let (el, new_acc) = slam(ctx, gate.clone(), cell(n, acc))?.as_cell()?;
574+ let (el, new_acc) = slam(ctx, gate.clone(), cell(&n, &acc))?.as_cell()?;
569 acc = new_acc;
575 acc = new_acc;
570 res.push(el);
576 res.push(el);
571 }
577 }
572
578
573− Some(cell(Noun::list_refs(res.iter().cloned()), acc))
579+ Some(cell(&Noun::list_refs(res.iter().cloned()), &acc))
574};
580};
575
581
576static TURN: Jet = |ctx, n| {
582static TURN: Jet = |ctx, n| {
nock/src/main.rs+2−2
@@ -170,8 +170,8 @@ fn build(root: PathBuf, output: PathBuf) -> Result<(), std::io::Error> {
170 let hoon_hoon_ast_nock = include_bytes!("../res/hoon-hoon-ast.nock");
170 let hoon_hoon_ast_nock = include_bytes!("../res/hoon-hoon-ast.nock");
171 let hoon_hoon_ast = cue_bytes(hoon_hoon_ast_nock);
171 let hoon_hoon_ast = cue_bytes(hoon_hoon_ast_nock);
172 cell(
172 cell(
173− Rc::new(Noun::Atom(Atom::from_bytes_le(b"tsgl"))),
173+ &Noun::Atom(Atom::from_bytes_le(b"tsgl")),
174− cell(hoon_hoon_ast, root_ast),
174+ &cell(&hoon_hoon_ast, &root_ast),
175 )
175 )
176 };
176 };
177
177
nock/src/noun.rs+18−23
@@ -80,15 +80,15 @@ impl Noun {
80 }
80 }
81
81
82 pub fn list<I: Iterator<Item = Noun> + DoubleEndedIterator>(l: I) -> Rc<Noun> {
82 pub fn list<I: Iterator<Item = Noun> + DoubleEndedIterator>(l: I) -> Rc<Noun> {
83− l.rfold(Rc::new(Noun::SIG), |tail, head| cell(Rc::new(head), tail))
83+ l.rfold(Rc::new(Noun::SIG), |tail, head| cell(&head, &tail))
84 }
84 }
85
85
86 pub fn list_refs<I: Iterator<Item = Rc<Noun>> + DoubleEndedIterator>(l: I) -> Rc<Noun> {
86 pub fn list_refs<I: Iterator<Item = Rc<Noun>> + DoubleEndedIterator>(l: I) -> Rc<Noun> {
87− l.rfold(Rc::new(Noun::SIG), |tail, head| cell(head, tail))
87+ l.rfold(Rc::new(Noun::SIG), |tail, head| cell(&head, &tail))
88 }
88 }
89
89
90 pub fn unit(self: Rc<Self>) -> Rc<Noun> {
90 pub fn unit(self: Rc<Self>) -> Rc<Noun> {
91− cell(Rc::new(Noun::SIG), self)
91+ cell(&Noun::SIG, &self)
92 }
92 }
93
93
94 pub fn from_unit(unit: Option<Rc<Noun>>) -> Rc<Noun> {
94 pub fn from_unit(unit: Option<Rc<Noun>>) -> Rc<Noun> {
@@ -232,10 +232,7 @@ impl Noun {
232 }
232 }
233
233
234 pub fn from_hair(hair: &Hair) -> Rc<Self> {
234 pub fn from_hair(hair: &Hair) -> Rc<Self> {
235− cell(
236− Rc::new(Noun::from_u32(hair.line)),
237− Rc::new(Noun::from_u32(hair.column)),
235+ cell(&Noun::from_u32(hair.line), &Noun::from_u32(hair.column))
238− )
239 }
236 }
240
237
241 pub fn as_nail(self: &Self) -> Option<Nail> {
238 pub fn as_nail(self: &Self) -> Option<Nail> {
@@ -293,13 +290,14 @@ pub struct Edge {
293
290
294impl Edge {
291impl Edge {
295 pub fn as_noun(self: &Self) -> Rc<Noun> {
292 pub fn as_noun(self: &Self) -> Rc<Noun> {
296− cell(
297− self.hair.as_noun(),
298− match self.result.clone() {
293+ let foo = match self.result.clone() {
299− None => Rc::new(Noun::SIG),
294+ None => &Noun::SIG,
295+ Some((result, nail)) => {
300− Some((result, nail)) => cell(Rc::new(Noun::SIG), cell(result, nail.as_noun())),
296+ let foo = cell(&result, &nail.as_noun());
297+ &cell(&Noun::SIG, &foo)
301− },
298+ }
302− )
299+ };
300+ cell(&self.hair.as_noun(), foo)
303 }
301 }
304}
302}
305
303
@@ -311,10 +309,7 @@ pub struct Hair {
311
309
312impl Hair {
310impl Hair {
313 pub fn as_noun(self: &Self) -> Rc<Noun> {
311 pub fn as_noun(self: &Self) -> Rc<Noun> {
314− cell(
315− Rc::new(Noun::from_u32(self.line)),
316− Rc::new(Noun::from_u32(self.column)),
312+ cell(&Noun::from_u32(self.line), &Noun::from_u32(self.column))
317− )
318 }
313 }
319}
314}
320
315
@@ -326,7 +321,7 @@ pub struct Nail {
326
321
327impl Nail {
322impl Nail {
328 pub fn as_noun(self: &Self) -> Rc<Noun> {
323 pub fn as_noun(self: &Self) -> Rc<Noun> {
329− cell(self.hair.as_noun(), self.rest.clone())
324+ cell(&self.hair.as_noun(), &self.rest)
330 }
325 }
331}
326}
332
327
@@ -399,14 +394,14 @@ fn print_noun(noun: Rc<Noun>, is_rhs: bool) -> String {
399 }
394 }
400}
395}
401
396
402−pub fn cell(p: Rc<Noun>, q: Rc<Noun>) -> Rc<Noun> {
397+pub fn cell(p: &Noun, q: &Noun) -> Rc<Noun> {
403 Rc::new(naked_cell(p, q))
398 Rc::new(naked_cell(p, q))
404}
399}
405
400
406−pub fn naked_cell(p: Rc<Noun>, q: Rc<Noun>) -> Noun {
401+pub fn naked_cell(p: &Noun, q: &Noun) -> Noun {
407 Noun::Cell {
402 Noun::Cell {
408− p: p.clone(),
403+ p: Rc::new(p.clone()),
409− q: q.clone(),
404+ q: Rc::new(q.clone()),
410 hash: Cell::new(None),
405 hash: Cell::new(None),
411 compiled_gate: None,
406 compiled_gate: None,
412 }
407 }