Q:

How to pass a Box value to a function

If I have the following method:
fn borrow_func(c: Box<i32>) {
    // some code
}

fn main(){
    let a = Box::new(5i32);
    let b = a;

    borrow_func(b);
    println!("b contains: {}", b);
}

because the resource in heap will be released in the borrow_func, Is there any way to avoid this?
If I try to use a borrow in the borrow_func like following, I will get a 
compile error:

expected Box<i32>,
  found &_

fn borrow_func(&c: Box<i32>) {
}

It seem that the compiler do not the pointer type for b? 
How can I make this work ?

A:

Your borrow_func actually takes the ownership over the boxed variable. You should change the signature of borrow_func to reflect the borrowing, like this:
fn borrow_func(c: &i32) {
    // some code
}

fn borrow_func2(c: &Box<i32>) {
    // some code
}

fn main(){
    let a = Box::new(5i32);
    let b = a;

    borrow_func(&b);
    borrow_func2(&b);
    println!("b contains: {}", b);
}

You can use a simple reference of an &Box as well. For more information about borrowing, check: https://doc.rust-lang.org/book/references-and-borrowing.html
Vladimir added a useful information: 

pointers to boxes like &Box are unidiomatic and completely pointless - they introduce unnecessary double indirection and give nothing useful back. Just plain reference (&i32) is always the way to go.

