]>
git.proxmox.com Git - rustc.git/blob - tests/ui/cross-crate/auxiliary/cci_nested_lib.rs
1 use std
::cell
::RefCell
;
3 pub struct Entry
<A
,B
> {
8 pub struct alist
<A
,B
> {
9 eq_fn
: extern "Rust" fn(A
,A
) -> bool
,
10 data
: Box
<RefCell
<Vec
<Entry
<A
,B
>>>>,
13 pub fn alist_add
<A
:'
static,B
:'
static>(lst
: &alist
<A
,B
>, k
: A
, v
: B
) {
14 let mut data
= lst
.data
.borrow_mut();
15 (*data
).push(Entry{key:k, value:v}
);
18 pub fn alist_get
<A
:Clone
+ '
static,
23 let eq_fn
= lst
.eq_fn
;
24 let data
= lst
.data
.borrow();
25 for entry
in &(*data
) {
26 if eq_fn(entry
.key
.clone(), k
.clone()) {
27 return entry
.value
.clone();
34 pub fn new_int_alist
<B
:'
static>() -> alist
<isize, B
> {
35 fn eq_int(a
: isize, b
: isize) -> bool { a == b }
38 data
: Box
::new(RefCell
::new(Vec
::new())),
43 pub fn new_int_alist_2
<B
:'
static>() -> alist
<isize, B
> {
45 fn eq_int(a
: isize, b
: isize) -> bool { a == b }
48 data
: Box
::new(RefCell
::new(Vec
::new())),