Fix &'static str -> &str.

master
WangRunji 7 years ago
parent 20d2ac2eca
commit 0e6510c84f

@ -4,7 +4,7 @@ version = "0.0.1"
authors = ["WangRunji <wangrunji0408@163.com>"]
[lib]
crate-type = ["staticlib"]
#crate-type = ["staticlib"]
[profile.dev]
panic = 'abort' # prevent `_Unwind_Resume` link error

@ -32,6 +32,9 @@ pub mod c_interface;
#[cfg(test)]
mod tests;
pub use sfs::*;
pub use vfs::*;
#[cfg(feature = "ucore")]
#[global_allocator]
pub static UCORE_ALLOCATOR: c_interface::UcoreAllocator = c_interface::UcoreAllocator{};

@ -96,7 +96,7 @@ impl INode {
}
}
/// Only for Dir
fn get_file_inode_id(&self, name: &'static str) -> Option<INodeId> {
fn get_file_inode_id(&self, name: &str) -> Option<INodeId> {
(0..self.disk_inode.blocks)
.map(|i| {
use vfs::INode;
@ -249,7 +249,7 @@ impl vfs::INode for INode {
assert_eq!(self.disk_inode.type_, FileType::File, "resize is only available on file");
self._resize(len)
}
fn create(&mut self, name: &'static str, type_: vfs::FileType) -> vfs::Result<Ptr<vfs::INode>> {
fn create(&mut self, name: &str, type_: vfs::FileType) -> vfs::Result<Ptr<vfs::INode>> {
let fs = self.fs.upgrade().unwrap();
let info = self.info().unwrap();
assert_eq!(info.type_, vfs::FileType::Dir);
@ -273,7 +273,7 @@ impl vfs::INode for INode {
Ok(inode)
}
fn lookup(&self, path: &'static str) -> vfs::Result<Ptr<vfs::INode>> {
fn lookup(&self, path: &str) -> vfs::Result<Ptr<vfs::INode>> {
let fs = self.fs.upgrade().unwrap();
let info = self.info().unwrap();
assert_eq!(info.type_, vfs::FileType::Dir);

@ -82,15 +82,15 @@ impl Debug for Str32 {
write!(f, "{}", self.as_ref())
}
}
impl From<&'static str> for Str256 {
fn from(s: &'static str) -> Self {
impl<'a> From<&'a str> for Str256 {
fn from(s: &'a str) -> Self {
let mut ret = [0u8; 256];
ret[0..s.len()].copy_from_slice(s.as_ref());
Str256(ret)
}
}
impl From<&'static str> for Str32 {
fn from(s: &'static str) -> Self {
impl<'a> From<&'a str> for Str32 {
fn from(s: &'a str) -> Self {
let mut ret = [0u8; 32];
ret[0..s.len()].copy_from_slice(s.as_ref());
Str32(ret)

@ -22,8 +22,8 @@ pub trait INode: Debug {
// fn name_file(&mut self) -> Result<()>;
// fn reclaim(&mut self) -> Result<()>;
fn resize(&mut self, len: usize) -> Result<()>;
fn create(&mut self, name: &'static str, type_: FileType) -> Result<INodePtr>;
fn lookup(&self, path: &'static str) -> Result<INodePtr>;
fn create(&mut self, name: &str, type_: FileType) -> Result<INodePtr>;
fn lookup(&self, path: &str) -> Result<INodePtr>;
fn list(&self) -> Result<Vec<String>>;
// fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>;
fn fs(&self) -> Weak<FileSystem>;

Loading…
Cancel
Save