File: Return inner contents as references, not cloned

This commit is contained in:
Matthias Beyer 2015-12-27 23:26:08 +01:00
parent 030b5fc888
commit f774effabb
2 changed files with 8 additions and 8 deletions

View file

@ -32,20 +32,20 @@ pub struct File<'a> {
impl<'a> File<'a> {
pub fn header(&self) -> FileHeaderData {
self.header.clone()
pub fn header(&self) -> &FileHeaderData {
&self.header
}
pub fn data(&self) -> String {
self.data.clone()
pub fn data(&self) -> &String {
&self.data
}
pub fn contents(&self) -> (FileHeaderData, String) {
pub fn contents(&self) -> (&FileHeaderData, &String) {
(self.header(), self.data())
}
pub fn id(&self) -> FileID {
self.id.clone()
pub fn id(&self) -> &FileID {
&self.id
}
pub fn owner(&self) -> &'a Module<'a> {

View file

@ -105,7 +105,7 @@ impl FilePrinter for TablePrinter {
let cell_i = Cell::new(&format!("{}", i)[..]);
let cell_o = Cell::new(&format!("{}", file.owner().name())[..]);
let id : String = file.id().into();
let id : String = file.id().clone().into();
let cell_id = Cell::new(&id[..]);
let row = Row::new(vec![cell_i, cell_o, cell_id]);
tab.add_row(row);