1use super::*;
4use super::types::*;
5use super::c_api::*;
6
7pub struct Builder {
9 pub(crate) builder: Option<LLVMBuilderRef>,
10}
11
12impl Builder {
13 pub fn build_alloca(&self, ty: Type) -> Value {
15 Value {
16 value: unsafe {
17 LLVMBuildAlloca(self.builder.unwrap(), ty.ty, into_c("").as_ptr())
18 }
19 }
20 }
21
22 pub fn build_malloc(&self, ty: Type) -> Value {
24 Value {
25 value: unsafe {
26 LLVMBuildMalloc(self.builder.unwrap(), ty.ty, into_c("").as_ptr())
27 }
28 }
29 }
30
31 pub fn build_array_alloca(&self, ty: Type, count: u32) -> Value {
33 Value {
34 value: unsafe {
35 LLVMBuildArrayAlloca(self.builder.unwrap(), ty.ty, ty_i32().const_int(count as u64).value, into_c("").as_ptr())
36 }
37 }
38 }
39
40 pub fn build_array_malloc(&self, ty: Type, count: u32) -> Value {
42 Value {
43 value: unsafe {
44 LLVMBuildArrayMalloc(self.builder.unwrap(), ty.ty, ty_i32().const_int(count as u64).value, into_c("").as_ptr())
45 }
46 }
47 }
48
49 pub fn build_free(&self, ptr: Value) -> Value {
51 Value {
52 value: unsafe {
53 LLVMBuildFree(self.builder.unwrap(), ptr.value)
54 }
55 }
56 }
57
58 pub fn build_call(&self, func: Value, args: Vec<Value>) -> Value {
60 Value {
61 value: unsafe {
62 LLVMBuildCall(self.builder.unwrap(), func.value, val_vec(&args).as_mut_ptr(), args.len() as u32, into_c("").as_ptr())
63 }
64 }
65 }
66
67 pub fn build_struct_init(&self, ty: Type, elements: Vec<Value>) -> Value {
69 let mut init_elems = Vec::new();
70 let mut append_elems = Vec::new();
71 for (index, element) in elements.into_iter().enumerate() {
72 if element.is_constant() {
73 init_elems.push(element);
74 } else {
75 init_elems.push(element.ty().undef());
76 append_elems.push((index, element));
77 }
78 }
79 let mut agg = ty.const_struct(init_elems);
80 for (index, element) in append_elems.into_iter() {
81 agg = self.build_insert_value(agg, element, index as u32).name(format!("insert_{}", index));
82 }
83 agg
84 }
85
86 pub fn build_struct_alloca_init(&self, ty: Type, elements: Vec<Value>) -> Value {
88 let ptr = self.build_alloca(ty);
89 for (index, element) in elements.into_iter().enumerate() {
90 let elem_ptr = self.build_struct_gep(ptr, index as u32).name(format!("init_{}", index));
91 self.build_store(element, elem_ptr);
92 }
93 ptr
94 }
95
96 pub fn build_struct_malloc_init(&self, ty: Type, elements: Vec<Value>) -> Value {
98 let ptr = self.build_malloc(ty);
99 for (index, element) in elements.into_iter().enumerate() {
100 let elem_ptr = self.build_struct_gep(ptr, index as u32).name(format!("init_{}", index));
101 self.build_store(element, elem_ptr);
102 }
103 ptr
104 }
105
106 pub fn build_insert_value(&self, agg: Value, elt: Value, index: u32) -> Value {
108 Value {
109 value: unsafe {
110 LLVMBuildInsertValue(self.builder.unwrap(), agg.value, elt.value, index, into_c("").as_ptr())
111 }
112 }
113 }
114
115 pub fn build_extract_value(&self, agg: Value, index: u32) -> Value {
117 Value {
118 value: unsafe {
119 LLVMBuildExtractValue(self.builder.unwrap(), agg.value, index, into_c("").as_ptr())
120 }
121 }
122 }
123
124 pub fn build_gep(&self, ptr: Value, indices: Vec<Value>) -> Value {
126 Value {
127 value: unsafe {
128 LLVMBuildGEP(self.builder.unwrap(), ptr.value,
129 val_vec(&indices).as_mut_ptr(), indices.len() as u32, into_c("").as_ptr())
130 }
131 }
132 }
133
134 pub fn build_struct_gep(&self, ptr: Value, index: u32) -> Value {
136 Value {
137 value: unsafe {
138 LLVMBuildStructGEP(self.builder.unwrap(), ptr.value, index, into_c("").as_ptr())
139 }
140 }
141 }
142
143 pub fn build_inbounds_gep(&self, ptr: Value, indices: Vec<Value>) -> Value {
145 Value {
146 value: unsafe {
147 LLVMBuildGEP(self.builder.unwrap(), ptr.value,
148 val_vec(&indices).as_mut_ptr(), indices.len() as u32, into_c("").as_ptr())
149 }
150 }
151 }
152
153 pub fn build_global_string<S>(&self, string: S) -> Value where S: AsRef<str> {
155 Value {
156 value: unsafe {
157 LLVMBuildGlobalString(self.builder.unwrap(), into_c(string).as_ptr(), into_c("").as_ptr())
158 }
159 }
160 }
161
162 pub fn build_global_string_ptr<S>(&self, string: S) -> Value where S: AsRef<str> {
164 Value {
165 value: unsafe {
166 LLVMBuildGlobalStringPtr(self.builder.unwrap(), into_c(string).as_ptr(), into_c("").as_ptr())
167 }
168 }
169 }
170
171 pub fn build_store(&self, val: Value, ptr: Value) {
173 unsafe {
174 LLVMBuildStore(self.builder.unwrap(), val.value, ptr.value);
175 }
176 }
177
178 pub fn build_load(&self, ptr: Value) -> Value {
180 Value {
181 value: unsafe {
182 LLVMBuildLoad(self.builder.unwrap(), ptr.value, into_c("").as_ptr())
183 }
184 }
185 }
186
187 pub fn build_array_alloca_store(&self, ty: Type, elements: Vec<Value>) -> Value {
189 let mut agg = ty_array(ty, elements.len() as u32).undef();
190 for (i, element) in elements.into_iter().enumerate() {
191 agg = self.build_insert_value(agg, element, i as u32).name(format!("insert_elem_{}", i));
192 }
193 self.build_pointer_cast(self.build_alloca_store(agg), ty.pointer())
194 }
195
196 pub fn build_array_malloc_store(&self, ty: Type, elements: Vec<Value>) -> Value {
198 let mut agg = ty_array(ty, elements.len() as u32).undef();
199 for (i, element) in elements.into_iter().enumerate() {
200 agg = self.build_insert_value(agg, element, i as u32).name(format!("insert_elem_{}", i));
201 }
202 self.build_pointer_cast(self.build_malloc_store(agg), ty.pointer())
203 }
204
205 pub fn build_alloca_store(&self, val: Value) -> Value {
207 let ptr = self.build_alloca(val.ty());
208 self.build_store(val, ptr);
209 ptr
210 }
211
212 pub fn build_malloc_store(&self, val: Value) -> Value {
214 let ptr = self.build_malloc(val.ty());
215 self.build_store(val, ptr);
216 ptr
217 }
218
219 pub fn build_load_free(&self, ptr: Value) -> Value {
221 let val = self.build_load(ptr);
222 self.build_free(ptr);
223 val
224 }
225
226 pub fn build_int_to_ptr(&self, val: Value, ptr_ty: Type) -> Value {
228 Value {
229 value: unsafe {
230 LLVMBuildIntToPtr(self.builder.unwrap(), val.value, ptr_ty.ty, into_c("").as_ptr())
231 }
232 }
233 }
234
235 pub fn build_ptr_to_int(&self, ptr: Value, val_ty: Type) -> Value {
237 Value {
238 value: unsafe {
239 LLVMBuildPtrToInt(self.builder.unwrap(), ptr.value, val_ty.ty, into_c("").as_ptr())
240 }
241 }
242 }
243
244 pub fn build_pointer_cast(&self, ptr: Value, ty: Type) -> Value {
246 Value {
247 value: unsafe {
248 LLVMBuildPointerCast(self.builder.unwrap(), ptr.value, ty.ty, into_c("").as_ptr())
249 }
250 }
251 }
252
253 pub fn build_int_cast(&self, val: Value, ty: Type) -> Value {
255 Value {
256 value: unsafe {
257 LLVMBuildIntCast(self.builder.unwrap(), val.value, ty.ty, into_c("").as_ptr())
258 }
259 }
260 }
261
262 pub fn build_bit_cast(&self, val: Value, ty: Type) -> Value {
264 Value {
265 value: unsafe {
266 LLVMBuildBitCast(self.builder.unwrap(), val.value, ty.ty, into_c("").as_ptr())
267 }
268 }
269 }
270
271 pub fn build_float_cast(&self, val: Value, ty: Type) -> Value {
273 Value {
274 value: unsafe {
275 LLVMBuildFPCast(self.builder.unwrap(), val.value, ty.ty, into_c("").as_ptr())
276 }
277 }
278 }
279
280 pub fn build_ret_void(&self) -> Value {
282 Value {
283 value: unsafe {
284 LLVMBuildRetVoid(self.builder.unwrap())
285 }
286 }
287 }
288
289 pub fn build_ret(&self, val: Value) -> Value where {
291 Value {
292 value: unsafe {
293 LLVMBuildRet(self.builder.unwrap(), val.value)
294 }
295 }
296 }
297
298 pub fn build_unreachable(&self) {
300 unsafe {
301 LLVMBuildUnreachable(self.builder.unwrap());
302 }
303 }
304
305 pub fn build_br(&self, block: BasicBlock) {
307 unsafe {
308 LLVMBuildBr(self.builder.unwrap(), block.basic_block);
309 }
310 }
311
312 pub fn build_if(&self, condition: Value, then_block: BasicBlock, else_block: BasicBlock) {
314 unsafe {
315 LLVMBuildCondBr(self.builder.unwrap(), condition.value, then_block.basic_block, else_block.basic_block);
316 }
317 }
318
319 pub fn build_switch(&self, val: Value, cases: Vec<(Value, BasicBlock)>, default: BasicBlock) {
321 unsafe {
322 let switch = LLVMBuildSwitch(self.builder.unwrap(), val.value, default.basic_block, cases.len() as u32);
323 for (val, bb) in cases {
324 LLVMAddCase(switch, val.value, bb.basic_block);
325 }
326 }
327 }
328
329 pub fn build_phi(&self, incoming: Vec<(Value, BasicBlock)>) -> Value {
331 Value {
332 value: unsafe {
333 if incoming.is_empty() {
334 panic!("phi node must have an incoming block list");
335 } else {
336 let phi = LLVMBuildPhi(
337 self.builder.unwrap(),
338 incoming[0].0.ty().ty,
339 into_c("").as_ptr()
340 );
341 let len = incoming.len();
342 let mut values = Vec::new();
343 let mut blocks = Vec::new();
344 for (val, block) in incoming {
345 values.push(val.value);
346 blocks.push(block.basic_block);
347 }
348 LLVMAddIncoming(phi, values.as_mut_ptr(), blocks.as_mut_ptr(), len as u32);
349 phi
350 }
351 }
352 }
353 }
354
355 pub fn position_in_block(&self, bb: BasicBlock, val: Value) {
357 unsafe {
358 LLVMPositionBuilder(self.builder.unwrap(), bb.basic_block, val.value);
359 }
360 }
361
362 pub fn position_at_end(&self, bb: BasicBlock) {
364 unsafe {
365 LLVMPositionBuilderAtEnd(self.builder.unwrap(), bb.basic_block);
366 }
367 }
368
369 pub fn position_before(&self, val: Value) {
371 unsafe {
372 LLVMPositionBuilderBefore(self.builder.unwrap(), val.value);
373 }
374 }
375
376 pub fn inner(&self) -> LLVMBuilderRef {
378 self.builder.unwrap()
379 }
380
381 pub unsafe fn into_inner(mut self) -> LLVMBuilderRef {
383 self.builder.take().unwrap()
384 }
385
386 pub fn build_is_null(&self, val: Value) -> Value {
388 Value {
389 value: unsafe {
390 LLVMBuildIsNull(self.builder.unwrap(), val.value, into_c("").as_ptr())
391 }
392 }
393 }
394
395 pub fn build_is_not_null(&self, val: Value) -> Value {
397 Value {
398 value: unsafe {
399 LLVMBuildIsNotNull(self.builder.unwrap(), val.value, into_c("").as_ptr())
400 }
401 }
402 }
403
404 pub fn build_int_add(&self, a: Value, b: Value) -> Value {
406 Value {
407 value: unsafe {
408 LLVMBuildAdd(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
409 }
410 }
411 }
412
413 pub fn build_int_sub(&self, a: Value, b: Value) -> Value {
415 Value {
416 value: unsafe {
417 LLVMBuildSub(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
418 }
419 }
420 }
421
422 pub fn build_int_mul(&self, a: Value, b: Value) -> Value {
424 Value {
425 value: unsafe {
426 LLVMBuildMul(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
427 }
428 }
429 }
430
431 pub fn build_int_udiv(&self, a: Value, b: Value) -> Value {
433 Value {
434 value: unsafe {
435 LLVMBuildUDiv(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
436 }
437 }
438 }
439
440 pub fn build_int_sdiv(&self, a: Value, b: Value) -> Value {
442 Value {
443 value: unsafe {
444 LLVMBuildSDiv(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
445 }
446 }
447 }
448
449 pub fn build_int_urem(&self, a: Value, b: Value) -> Value {
451 Value {
452 value: unsafe {
453 LLVMBuildSRem(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
454 }
455 }
456 }
457
458 pub fn build_int_srem(&self, a: Value, b: Value) -> Value {
460 Value {
461 value: unsafe {
462 LLVMBuildSRem(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
463 }
464 }
465 }
466
467 pub fn build_shl(&self, a: Value, b: Value) -> Value {
469 Value {
470 value: unsafe {
471 LLVMBuildShl(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
472 }
473 }
474 }
475
476 pub fn build_lshr(&self, a: Value, b: Value) -> Value {
478 Value {
479 value: unsafe {
480 LLVMBuildLShr(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
481 }
482 }
483 }
484
485 pub fn build_ashr(&self, a: Value, b: Value) -> Value {
487 Value {
488 value: unsafe {
489 LLVMBuildAShr(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
490 }
491 }
492 }
493
494 pub fn build_and(&self, a: Value, b: Value) -> Value {
496 Value {
497 value: unsafe {
498 LLVMBuildAnd(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
499 }
500 }
501 }
502
503 pub fn build_or(&self, a: Value, b: Value) -> Value {
505 Value {
506 value: unsafe {
507 LLVMBuildOr(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
508 }
509 }
510 }
511
512 pub fn build_xor(&self, a: Value, b: Value) -> Value {
514 Value {
515 value: unsafe {
516 LLVMBuildXor(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
517 }
518 }
519 }
520
521 pub fn build_int_eq(&self, a: Value, b: Value) -> Value {
523 Value {
524 value: unsafe {
525 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntEQ, a.value, b.value, into_c("").as_ptr())
526 }
527 }
528 }
529
530 pub fn build_int_ne(&self, a: Value, b: Value) -> Value {
532 Value {
533 value: unsafe {
534 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntNE, a.value, b.value, into_c("").as_ptr())
535 }
536 }
537 }
538
539 pub fn build_int_ule(&self, a: Value, b: Value) -> Value {
541 Value {
542 value: unsafe {
543 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntULE, a.value, b.value, into_c("").as_ptr())
544 }
545 }
546 }
547
548 pub fn build_int_ult(&self, a: Value, b: Value) -> Value {
550 Value {
551 value: unsafe {
552 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntULT, a.value, b.value, into_c("").as_ptr())
553 }
554 }
555 }
556
557 pub fn build_int_uge(&self, a: Value, b: Value) -> Value {
559 Value {
560 value: unsafe {
561 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntUGE, a.value, b.value, into_c("").as_ptr())
562 }
563 }
564 }
565
566 pub fn build_int_ugt(&self, a: Value, b: Value) -> Value {
568 Value {
569 value: unsafe {
570 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntUGT, a.value, b.value, into_c("").as_ptr())
571 }
572 }
573 }
574
575 pub fn build_int_sle(&self, a: Value, b: Value) -> Value {
577 Value {
578 value: unsafe {
579 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntSLE, a.value, b.value, into_c("").as_ptr())
580 }
581 }
582 }
583
584 pub fn build_int_slt(&self, a: Value, b: Value) -> Value {
586 Value {
587 value: unsafe {
588 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntSLT, a.value, b.value, into_c("").as_ptr())
589 }
590 }
591 }
592
593 pub fn build_int_sge(&self, a: Value, b: Value) -> Value {
595 Value {
596 value: unsafe {
597 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntSGE, a.value, b.value, into_c("").as_ptr())
598 }
599 }
600 }
601
602 pub fn build_int_sgt(&self, a: Value, b: Value) -> Value {
604 Value {
605 value: unsafe {
606 LLVMBuildICmp(self.builder.unwrap(), LLVMIntPredicate::LLVMIntSGT, a.value, b.value, into_c("").as_ptr())
607 }
608 }
609 }
610
611 pub fn build_float_add(&self, a: Value, b: Value) -> Value {
613 Value {
614 value: unsafe {
615 LLVMBuildFAdd(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
616 }
617 }
618 }
619
620 pub fn build_float_sub(&self, a: Value, b: Value) -> Value {
622 Value {
623 value: unsafe {
624 LLVMBuildFSub(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
625 }
626 }
627 }
628
629 pub fn build_float_mul(&self, a: Value, b: Value) -> Value {
631 Value {
632 value: unsafe {
633 LLVMBuildFMul(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
634 }
635 }
636 }
637
638 pub fn build_float_div(&self, a: Value, b: Value) -> Value {
640 Value {
641 value: unsafe {
642 LLVMBuildFDiv(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
643 }
644 }
645 }
646
647 pub fn build_float_rem(&self, a: Value, b: Value) -> Value {
649 Value {
650 value: unsafe {
651 LLVMBuildFRem(self.builder.unwrap(), a.value, b.value, into_c("").as_ptr())
652 }
653 }
654 }
655
656 pub fn build_float_eq(&self, a: Value, b: Value) -> Value {
658 Value {
659 value: unsafe {
660 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealUEQ, a.value, b.value, into_c("").as_ptr())
661 }
662 }
663 }
664
665 pub fn build_float_ne(&self, a: Value, b: Value) -> Value {
667 Value {
668 value: unsafe {
669 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealUNE, a.value, b.value, into_c("").as_ptr())
670 }
671 }
672 }
673
674 pub fn build_float_le(&self, a: Value, b: Value) -> Value {
676 Value {
677 value: unsafe {
678 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealULE, a.value, b.value, into_c("").as_ptr())
679 }
680 }
681 }
682
683 pub fn build_float_lt(&self, a: Value, b: Value) -> Value {
685 Value {
686 value: unsafe {
687 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealULT, a.value, b.value, into_c("").as_ptr())
688 }
689 }
690 }
691
692 pub fn build_float_ge(&self, a: Value, b: Value) -> Value {
694 Value {
695 value: unsafe {
696 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealUGE, a.value, b.value, into_c("").as_ptr())
697 }
698 }
699 }
700
701 pub fn build_float_gt(&self, a: Value, b: Value) -> Value {
703 Value {
704 value: unsafe {
705 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealUGT, a.value, b.value, into_c("").as_ptr())
706 }
707 }
708 }
709
710 pub fn build_float_ord_eq(&self, a: Value, b: Value) -> Value {
712 Value {
713 value: unsafe {
714 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealOEQ, a.value, b.value, into_c("").as_ptr())
715 }
716 }
717 }
718
719 pub fn build_float_ord_ne(&self, a: Value, b: Value) -> Value {
721 Value {
722 value: unsafe {
723 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealONE, a.value, b.value, into_c("").as_ptr())
724 }
725 }
726 }
727
728 pub fn build_float_ord_le(&self, a: Value, b: Value) -> Value {
730 Value {
731 value: unsafe {
732 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealOLE, a.value, b.value, into_c("").as_ptr())
733 }
734 }
735 }
736
737 pub fn build_float_ord_lt(&self, a: Value, b: Value) -> Value {
739 Value {
740 value: unsafe {
741 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealOLT, a.value, b.value, into_c("").as_ptr())
742 }
743 }
744 }
745
746 pub fn build_float_ord_ge(&self, a: Value, b: Value) -> Value {
748 Value {
749 value: unsafe {
750 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealOGE, a.value, b.value, into_c("").as_ptr())
751 }
752 }
753 }
754
755 pub fn build_float_ord_gt(&self, a: Value, b: Value) -> Value {
757 Value {
758 value: unsafe {
759 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealOGT, a.value, b.value, into_c("").as_ptr())
760 }
761 }
762 }
763
764 pub fn build_float_is_ord(&self, a: Value, b: Value) -> Value {
766 Value {
767 value: unsafe {
768 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealORD, a.value, b.value, into_c("").as_ptr())
769 }
770 }
771 }
772
773 pub fn build_float_non_ord(&self, a: Value, b: Value) -> Value {
775 Value {
776 value: unsafe {
777 LLVMBuildFCmp(self.builder.unwrap(), LLVMRealPredicate::LLVMRealUNO, a.value, b.value, into_c("").as_ptr())
778 }
779 }
780 }
781}
782
783impl Deref for Builder {
784 type Target = LLVMBuilderRef;
785
786 fn deref(&self) -> &LLVMBuilderRef {
787 self.builder.as_ref().unwrap()
788 }
789}
790
791impl Drop for Builder {
792 fn drop(&mut self) {
793 if let Some(builder) = self.builder {
794 unsafe {
795 LLVMDisposeBuilder(builder);
796 }
797 }
798 }
799}
800
801impl Debug for Builder {
802 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
803 write!(f, "Builder")
804 }
805}