Skip to content

Commit

Permalink
Add box mut dyn trait regression test (#108)
Browse files Browse the repository at this point in the history
This resolves issue #34

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
  • Loading branch information
2 people authored and adpaco-aws committed Jul 26, 2021
1 parent 8453c0a commit a5b7c57
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rust-tests/cbmc-reg/FatPointers/boxmuttrait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::io::{sink, Write};

fn main() {
let mut log: Box<dyn Write + Send> = Box::new(sink());
let dest: Box<dyn Write + Send> = Box::new(log.as_mut());

let mut log2: Box<dyn Write + Send> = Box::new(sink());
let buffer = vec![1, 2, 3, 5, 8];
let num_bytes = log2.write(&buffer).unwrap();
assert!(num_bytes == 5);
}

0 comments on commit a5b7c57

Please sign in to comment.