-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed some structs, traits and variants. Fixed storage and dropping issues. Fully implemented ptr_metadata support. Cleaned up type interface to be more convenient. Added support for mutation of stored data. Separated library into more modules. Improved tests. Improved CI script and switch it to nightly Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
- Loading branch information
Showing
12 changed files
with
719 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug unit tests in library 'contiguous-mem'", | ||
"cargo": { | ||
"args": [ | ||
"test", | ||
"--no-run", | ||
"--lib", | ||
"--package=contiguous-mem" | ||
], | ||
"filter": { | ||
"name": "contiguous-mem", | ||
"kind": "lib" | ||
} | ||
}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug example 'ptr_metadata'", | ||
"cargo": { | ||
"args": [ | ||
"build", | ||
"--example=ptr_metadata", | ||
"--package=contiguous-mem" | ||
], | ||
"filter": { | ||
"name": "ptr_metadata", | ||
"kind": "example" | ||
} | ||
}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug unit tests in example 'ptr_metadata'", | ||
"cargo": { | ||
"args": [ | ||
"test", | ||
"--no-run", | ||
"--example=ptr_metadata", | ||
"--package=contiguous-mem" | ||
], | ||
"filter": { | ||
"name": "ptr_metadata", | ||
"kind": "example" | ||
} | ||
}, | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#![feature(ptr_metadata)] | ||
|
||
use contiguous_mem::{ | ||
ptr_metadata_ext::static_metadata, ContiguousMemoryRef, GrowableContiguousMemory, | ||
}; | ||
|
||
trait Greetable { | ||
fn print_hello(&self); | ||
} | ||
|
||
struct Person(String); | ||
impl Greetable for Person { | ||
fn print_hello(&self) { | ||
println!("Saying hello to person: {}", self.0); | ||
} | ||
} | ||
|
||
struct Dog(String); | ||
impl Greetable for Dog { | ||
fn print_hello(&self) { | ||
println!("Saying hello to dog: {}", self.0); | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut storage = GrowableContiguousMemory::new(4096); | ||
let person1 = storage.store(Person("Joe".to_string())); | ||
|
||
let person2: ContiguousMemoryRef<dyn Greetable> = storage | ||
.store(Person("Craig".to_string())) | ||
.as_dyn(static_metadata::<Person, dyn Greetable>()); | ||
|
||
let dog: ContiguousMemoryRef<dyn Greetable> = storage | ||
.store(Dog("Rover".to_string())) | ||
.as_dyn(static_metadata::<Dog, dyn Greetable>()); | ||
|
||
person1.print_hello(); | ||
person2.print_hello(); | ||
dog.print_hello(); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.