mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 23:37:56 +03:00
Replace a bunch of Into impls with Froms
This commit is contained in:
parent
7d004c48b1
commit
eadb28b95d
@ -90,9 +90,9 @@ pub enum OptLevel {
|
|||||||
Optimize,
|
Optimize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<OptimizationLevel> for OptLevel {
|
impl From<OptLevel> for OptimizationLevel {
|
||||||
fn into(self) -> OptimizationLevel {
|
fn from(level: OptLevel) -> Self {
|
||||||
match self {
|
match level {
|
||||||
OptLevel::Normal => OptimizationLevel::None,
|
OptLevel::Normal => OptimizationLevel::None,
|
||||||
OptLevel::Optimize => OptimizationLevel::Aggressive,
|
OptLevel::Optimize => OptimizationLevel::Aggressive,
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ pub enum RocCallResult<T> {
|
|||||||
Failure(*mut c_char),
|
Failure(*mut c_char),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Sized> Into<Result<T, String>> for RocCallResult<T> {
|
impl<T: Sized> From<RocCallResult<T>> for Result<T, String> {
|
||||||
fn into(self) -> Result<T, String> {
|
fn from(call_result: RocCallResult<T>) -> Self {
|
||||||
match self {
|
match call_result {
|
||||||
Success(value) => Ok(value),
|
Success(value) => Ok(value),
|
||||||
Failure(failure) => Err({
|
Failure(failure) => Err({
|
||||||
let raw = unsafe { CString::from_raw(failure) };
|
let raw = unsafe { CString::from_raw(failure) };
|
||||||
|
@ -117,21 +117,21 @@ impl From<InlinableString> for ModuleName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<InlinableString> for ModuleName {
|
impl From<ModuleName> for InlinableString {
|
||||||
fn into(self) -> InlinableString {
|
fn from(name: ModuleName) -> Self {
|
||||||
self.0
|
name.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<&'a InlinableString> for &'a ModuleName {
|
impl<'a> From<&'a ModuleName> for &'a InlinableString {
|
||||||
fn into(self) -> &'a InlinableString {
|
fn from(name: &'a ModuleName) -> Self {
|
||||||
&self.0
|
&name.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<Box<str>> for ModuleName {
|
impl From<ModuleName> for Box<str> {
|
||||||
fn into(self) -> Box<str> {
|
fn from(name: ModuleName) -> Self {
|
||||||
self.0.to_string().into()
|
name.0.to_string().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +197,9 @@ impl<'a> From<String> for Lowercase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<InlinableString> for Lowercase {
|
impl From<Lowercase> for InlinableString {
|
||||||
fn into(self) -> InlinableString {
|
fn from(lowercase: Lowercase) -> Self {
|
||||||
self.0
|
lowercase.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,21 +234,21 @@ impl From<InlinableString> for Ident {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<InlinableString> for Ident {
|
impl From<Ident> for InlinableString {
|
||||||
fn into(self) -> InlinableString {
|
fn from(ident: Ident) -> Self {
|
||||||
self.0
|
ident.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<&'a InlinableString> for &'a Ident {
|
impl<'a> From<&'a Ident> for &'a InlinableString {
|
||||||
fn into(self) -> &'a InlinableString {
|
fn from(ident: &'a Ident) -> Self {
|
||||||
&self.0
|
&ident.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<Box<str>> for Ident {
|
impl From<Ident> for Box<str> {
|
||||||
fn into(self) -> Box<str> {
|
fn from(ident: Ident) -> Self {
|
||||||
self.0.to_string().into()
|
ident.0.to_string().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,15 +42,15 @@ pub enum PackageOrPath<'a> {
|
|||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct ModuleName<'a>(&'a str);
|
pub struct ModuleName<'a>(&'a str);
|
||||||
|
|
||||||
impl<'a> Into<&'a str> for ModuleName<'a> {
|
impl<'a> From<ModuleName<'a>> for &'a str {
|
||||||
fn into(self) -> &'a str {
|
fn from(name: ModuleName<'a>) -> Self {
|
||||||
self.0
|
name.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<InlinableString> for ModuleName<'a> {
|
impl<'a> From<ModuleName<'a>> for InlinableString {
|
||||||
fn into(self) -> InlinableString {
|
fn from(name: ModuleName<'a>) -> InlinableString {
|
||||||
self.0.into()
|
name.0.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ impl VarStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Variable> for VarStore {
|
impl From<VarStore> for Variable {
|
||||||
fn into(self) -> Variable {
|
fn from(store: VarStore) -> Self {
|
||||||
Variable(self.next)
|
Variable(store.next)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +139,9 @@ impl fmt::Debug for OptVariable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Option<Variable>> for OptVariable {
|
impl From<OptVariable> for Option<Variable> {
|
||||||
fn into(self) -> Option<Variable> {
|
fn from(opt_var: OptVariable) -> Self {
|
||||||
self.into_variable()
|
opt_var.into_variable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,9 +180,9 @@ impl Variable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<OptVariable> for Variable {
|
impl From<Variable> for OptVariable {
|
||||||
fn into(self) -> OptVariable {
|
fn from(var: Variable) -> Self {
|
||||||
OptVariable(self.0)
|
OptVariable(var.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,9 +483,9 @@ impl fmt::Debug for Rank {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<usize> for Rank {
|
impl From<Rank> for usize {
|
||||||
fn into(self) -> usize {
|
fn from(rank: Rank) -> Self {
|
||||||
self.0
|
rank.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,11 +502,11 @@ pub enum RocCallResult<T> {
|
|||||||
Failure(*mut c_char),
|
Failure(*mut c_char),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Sized> Into<Result<T, &'static str>> for RocCallResult<T> {
|
impl<T: Sized> From<RocCallResult<T>> for Result<T, &'static str> {
|
||||||
fn into(self) -> Result<T, &'static str> {
|
fn from(call_result: RocCallResult<T>) -> Self {
|
||||||
use RocCallResult::*;
|
use RocCallResult::*;
|
||||||
|
|
||||||
match self {
|
match call_result {
|
||||||
Success(value) => Ok(value),
|
Success(value) => Ok(value),
|
||||||
Failure(failure) => Err({
|
Failure(failure) => Err({
|
||||||
let msg = unsafe {
|
let msg = unsafe {
|
||||||
@ -529,11 +529,11 @@ impl<T: Sized> Into<Result<T, &'static str>> for RocCallResult<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Sized + Copy> Into<Result<T, &'a str>> for &'a RocCallResult<T> {
|
impl<'a, T: Sized + Copy> From<&'a RocCallResult<T>> for Result<T, &'a str> {
|
||||||
fn into(self) -> Result<T, &'a str> {
|
fn from(call_result: &'a RocCallResult<T>) -> Self {
|
||||||
use RocCallResult::*;
|
use RocCallResult::*;
|
||||||
|
|
||||||
match self {
|
match call_result {
|
||||||
Success(value) => Ok(*value),
|
Success(value) => Ok(*value),
|
||||||
Failure(failure) => Err({
|
Failure(failure) => Err({
|
||||||
let msg = unsafe {
|
let msg = unsafe {
|
||||||
|
Loading…
Reference in New Issue
Block a user