Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Matrix Gatcha Bot
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Déploiement
Releases
Registre de modèles
Analyse
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Ce projet est archivé. Le dépôt et les autres ressources du projet sont en lecture seule.
Afficher davantage de fils d'Ariane
Kubat
Matrix Gatcha Bot
Validations
748952a0
Vérifiée
Valider
748952a0
rédigé
3 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Get ride of unsafe code!
parent
b34bca16
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/cmd/mod.rs
+16
-17
16 ajouts, 17 suppressions
src/cmd/mod.rs
avec
16 ajouts
et
17 suppressions
src/cmd/mod.rs
+
16
−
17
Voir le fichier @
748952a0
#![allow(dead_code)]
pub
mod
acl
;
pub
mod
acl
;
pub
mod
package
;
pub
mod
package
;
use
log
::
error
;
use
log
::
error
;
use
std
::{
process
::
abort
,
string
::
String
,
sync
::
Arc
};
use
std
::{
process
::
abort
,
string
::
String
,
sync
::
Arc
};
#[allow(dead_code)]
#[derive(Clone)]
#[derive(Clone)]
enum
CmdHandler
{
enum
CmdHandler
{
Simple
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
bool
>
),
Simple
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
bool
+
Send
+
Sync
>
),
Echo
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
String
>
),
Echo
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
String
+
Send
+
Sync
>
),
MultiEcho
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
Vec
<
String
>>
),
MultiEcho
(
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
Vec
<
String
>
+
Send
+
Sync
>
),
}
}
#[allow(dead_code)]
#[derive(Clone)]
#[derive(Clone)]
pub
struct
Cmd
{
pub
struct
Cmd
{
name
:
String
,
name
:
String
,
...
@@ -20,16 +20,11 @@ pub struct Cmd {
...
@@ -20,16 +20,11 @@ pub struct Cmd {
handler
:
CmdHandler
,
handler
:
CmdHandler
,
}
}
unsafe
impl
Sync
for
Cmd
{}
unsafe
impl
Send
for
Cmd
{}
impl
Cmd
{
impl
Cmd
{
#[allow(dead_code)]
pub
fn
matches
(
&
self
,
name
:
&
str
,
args
:
&
Vec
<&
str
>
)
->
bool
{
pub
fn
matches
(
&
self
,
name
:
&
str
,
args
:
&
Vec
<&
str
>
)
->
bool
{
(
self
.name
==
*
name
)
&&
(
self
.argc
as
usize
==
args
.len
())
(
self
.name
==
*
name
)
&&
(
self
.argc
as
usize
==
args
.len
())
}
}
#[allow(dead_code)]
pub
fn
exec
(
&
self
,
args
:
Vec
<&
str
>
)
->
String
{
pub
fn
exec
(
&
self
,
args
:
Vec
<&
str
>
)
->
String
{
if
args
.len
()
!=
self
.argc
as
usize
{
if
args
.len
()
!=
self
.argc
as
usize
{
error!
(
"Arg count doesn't match"
);
error!
(
"Arg count doesn't match"
);
...
@@ -46,13 +41,15 @@ impl Cmd {
...
@@ -46,13 +41,15 @@ impl Cmd {
}
}
}
}
#[allow(dead_code)]
pub
fn
get_name
(
&
self
)
->
&
str
{
pub
fn
get_name
(
&
self
)
->
&
str
{
&
self
.name
&
self
.name
}
}
#[allow(dead_code)]
pub
fn
new_simple
(
pub
fn
new_simple
(
name
:
String
,
argc
:
u32
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
bool
>
)
->
Cmd
{
name
:
String
,
argc
:
u32
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
bool
+
Send
+
Sync
>
,
)
->
Cmd
{
Cmd
{
Cmd
{
name
:
name
,
name
:
name
,
argc
:
argc
,
argc
:
argc
,
...
@@ -60,8 +57,11 @@ impl Cmd {
...
@@ -60,8 +57,11 @@ impl Cmd {
}
}
}
}
#[allow(dead_code)]
pub
fn
new_echo
(
pub
fn
new_echo
(
name
:
String
,
argc
:
u32
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
String
>
)
->
Cmd
{
name
:
String
,
argc
:
u32
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
String
+
Send
+
Sync
>
,
)
->
Cmd
{
Cmd
{
Cmd
{
name
:
name
,
name
:
name
,
argc
:
argc
,
argc
:
argc
,
...
@@ -69,11 +69,10 @@ impl Cmd {
...
@@ -69,11 +69,10 @@ impl Cmd {
}
}
}
}
#[allow(dead_code)]
pub
fn
new_multi_echo
(
pub
fn
new_multi_echo
(
name
:
String
,
name
:
String
,
argc
:
u32
,
argc
:
u32
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
Vec
<
String
>>
,
f
:
Arc
<
dyn
Fn
(
Vec
<&
str
>
)
->
Vec
<
String
>
+
Send
+
Sync
>
,
)
->
Cmd
{
)
->
Cmd
{
Cmd
{
Cmd
{
name
:
name
,
name
:
name
,
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter