blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
e5ab953306728f793292e4cd744bbe401185ad77 | Rust | pelian/bn-api | /db/src/models/enums.rs | UTF-8 | 7,683 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | use diesel::deserialize::{self, FromSql};
use diesel::pg::Pg;
use diesel::serialize::{self, IsNull, Output, ToSql};
use diesel::sql_types::*;
use std::fmt;
use std::io::Write;
use std::str;
use std::str::FromStr;
use utils::errors::EnumParseError;
macro_rules! string_enum {
($name:ident [$($value:ident),+]) => {
... | true |
7fdf6d9f779005e74e2f7868df15d222e95ff35c | Rust | Richard-W/efw | /src/console.rs | UTF-8 | 1,037 | 2.5625 | 3 | [
"MIT"
] | permissive | use super::efi;
struct StdOut;
impl core::fmt::Write for StdOut {
fn write_str(&mut self, string: &str) -> core::fmt::Result {
let mut con_out = efi::SystemTable::get().con_out();
ucs2::encode_with(string, |ch| {
let mut buffer: [u16; 2] = [0, 0];
buffer[0] = ch;
... | true |
3b94b8b0eab9bc0b6be532b844043c212cff9b7f | Rust | 19wintersp/Ook | /src/main.rs | UTF-8 | 1,828 | 2.90625 | 3 | [
"MIT"
] | permissive | mod error;
mod interpreter;
mod token;
mod tokeniser;
use interpreter::interpret;
use token::{ Token, TokenType };
use tokeniser::{ Config, tokenise };
use std::fs;
use clap::{ clap_app, Error };
static TOKEN_A: &str = "Ook.";
static TOKEN_B: &str = "Ook!";
static TOKEN_C: &str = "Ook?";
fn main() {
let matches =... | true |
28aa4df11d494ab8c352ef20d8f4f22d786505c2 | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-18352.rs | UTF-8 | 193 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
const X: &'static str = "12345";
fn test(s: String) -> bool {
match &*s {
X => true,
_ => false
}
}
fn main() {
assert!(test("12345".to_string()));
}
| true |
b358c5482dbd1740103149fb69f503782a99920b | Rust | sym233/leetcode_problems | /148. Sort List/148. Sort List.rs | UTF-8 | 1,820 | 3.359375 | 3 | [] | no_license | // Definition for singly-linked list.
// #[derive(PartialEq, Eq, Clone, Debug)]
// pub struct ListNode {
// pub val: i32,
// pub next: Option<Box<ListNode>>
// }
//
// impl ListNode {
// #[inline]
// fn new(val: i32) -> Self {
// ListNode {
// next: None,
// val
// }
// }
// }
impl Soluti... | true |
c8be57ddf8754e5f964434bf5cd04b89f04d8df3 | Rust | AdamKyle/story-teller | /world/src/world/person.rs | UTF-8 | 528 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::world::actions::{Action, OnAction};
use crate::world::conversation::{Converse};
#[derive(Clone, Debug)]
pub struct Person {
pub name: String,
pub actions: Option<HashMap<Action, OnAction>>,
pub conversation: Converse,
}
impl Person {
pub fn new(name: String,... | true |
30d57f7ffc6ee52ae895f075e75f1558f7604513 | Rust | etandel/adventofcode | /2021/d3/src/main.rs | UTF-8 | 3,234 | 3.046875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::path::Path;
type Readout = u16;
fn read_report<P>(path: P) -> (Vec<Readout>, usize)
where
P: AsRef<Path>,
{
let raw = fs::read_to_string(path).unwrap();
let bits_per_readout = raw.lines().next().unwrap().len();
let report = raw
.lines()
.filter_map... | true |
0fb425a7bf16c8c313b099c509ce4979154a9293 | Rust | Oyelowo/poem-gateway | /src/plugins/limit_count/redis.rs | UTF-8 | 2,497 | 2.515625 | 3 | [] | no_license | use anyhow::Result;
use chrono::Utc;
use redis::{
aio::ConnectionManager, Client, ConnectionAddr, ConnectionInfo, RedisConnectionInfo, Script,
};
use serde::{Deserialize, Serialize};
use crate::plugins::limit_count::storage::{Storage, StorageConfig};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCa... | true |
c44149fd48cf6e5041594ab1018e61c2e624a486 | Rust | kurotakazuki/floaout | /src/io/read/read_bytes.rs | UTF-8 | 1,859 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use mycrc::CRC;
use std::io::{Read, Result};
use std::mem;
pub trait ReadBytes: Sized {
/// This method reads bytes in big-endian byte order.
fn read_be_bytes<R: Read>(reader: &mut R) -> Result<Self>;
/// This method reads bytes in little-endian byte order.
fn read_le_bytes<R: Read>(reader: &mut R) -> ... | true |
2ff97d0dfe916e69060de6e83bb335f19ed19894 | Rust | JMARyA/jsonfs | /src/wrapper.rs | UTF-8 | 3,570 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::fs::read;
use std::ops::{Deref, DerefMut};
use serde::Serialize;
use serde::de::DeserializeOwned;
/// Wrapper around a Struct which gets saved to disk
pub struct JsonStruct<T: Serialize + DeserializeOwned + Default> {
_json_path: String,
_struct: T,
}
impl<T: Serialize + DeserializeOwned + Default> D... | true |
6022a733513404fba11efc9a5887b4855c92b424 | Rust | avantgardnerio/etheraudit | /rust/etheraudit/src/instruction.rs | UTF-8 | 6,296 | 2.78125 | 3 | [] | no_license | use std;
use program;
use op_codes;
use std::rc::*;
use expression;
use std::borrow::Borrow;
use std::ops::Deref;
use num::ToPrimitive;
use num;
use program::EvmStack;
pub type InstructionInputs = program::EvmStack;
pub type InstructionOutputs = program::EvmStack;
pub struct Instruction {
pub offset: usize,
... | true |
5965437d0cd94ebb2d12c57448f649a2ce49b822 | Rust | carrolita/shelfdb | /database/src/model/document.rs | UTF-8 | 629 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde_json::Value;
use std::{
collections::HashMap,
mem,
};
use uuid::Uuid;
#[derive(Clone, Deserialize, Serialize, Debug)]
pub struct Document {
pub id: Uuid,
pub fields: HashMap<String, Value>,
}
impl Document {
pub fn get_size(&self) -> usize {
let mut size = mem::size_of::<Self>();... | true |
6122ccc0e6711dd7bdb5ef6790b130df606cd3e4 | Rust | rmaugusto/mtxia | /src/fish/moviment_system.rs | UTF-8 | 1,716 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use bevy::{
core::Time,
ecs::{Query, Res},
math::{Quat, Vec3},
prelude::Transform,
};
use crate::shared::config::Config;
use super::{Fish, TurnFish};
const TURN_ANGLE: f32 = 0.261799; //15 degrees
pub(crate) fn move_fish_forward(
time: Res<Time>,
config: Res<Config>,
mut query: Query<(&m... | true |
b35130e7103ba0ebd0a88fddcddbb02ebf3afc14 | Rust | monocodus-demonstrations/flowbetween | /canvas/src/color.rs | UTF-8 | 3,945 | 3.9375 | 4 | [
"Apache-2.0"
] | permissive | use hsluv::*;
///
/// Possible formats of a colour value
///
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
pub enum ColorFormat {
Rgba,
Hsluv
}
///
/// Representation of a colour
///
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum Color {
Rgba(f32, f32, f32, f32),
Hsl... | true |
16274f9147025735e00aec07931011b8e78a31de | Rust | TheSpiritXIII/struct-variant | /tests/common/shape.rs | UTF-8 | 562 | 3.234375 | 3 | [
"MIT"
] | permissive | pub trait Shape {
fn area(&self) -> f64;
}
#[derive(Debug)]
pub struct Circle {
radius: usize,
}
impl Circle {
pub fn with_radius(radius: usize) -> Self {
Self { radius }
}
}
impl Shape for Circle {
fn area(&self) -> f64 {
core::f64::consts::PI * self.radius.pow(2) as f64
}
}
#[derive(Debug)]
pub struct R... | true |
bf47e9b450c99204a28a2830ce3786e603941a18 | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0640.solve-the-equation/solve-the-equation_test.go | UTF-8 | 716 | 2.796875 | 3 | [
"MIT"
] | permissive | package problem0640
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
equation string
ans string
}{
{
"-x=-1",
"x=1",
},
{
"x+5-3+x=6+x-2",
"x=2",
},
{
"x=x",
"Infinite solutions",
},
{
"2x=x",
"x=0",
},
{
"2x+3x-6x... | true |
947ab6c88d926cc891204102cbbcc03c96f69f97 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc152/src/bin/b.rs | UTF-8 | 185 | 2.609375 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
a: usize,
b: usize,
};
let ans = a.to_string().repeat(b).min(b.to_string().repeat(a));
println!("{}", ans);
}
| true |
a9b6e75cc20e4c0bdbb5bdffdb216a0d97e5e80c | Rust | aoki-soft/CryptoTool | /src/gui_mode.rs | UTF-8 | 6,408 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::context_menu;
use log::debug;
use native_windows_gui as nwg;
use std::rc::Rc;
pub fn gui() -> std::io::Result<()> {
debug!("GUIモードで起動しました。");
nwg::init().unwrap_or_else(|e| {
debug!("Failed to init Native Windows GUI");
debug!("{:?}", e);
std::process::exit(0);
});
... | true |
2c8fe2efe82d9b73b7cb77072bd032d22686c563 | Rust | forbesmyester/pipeawesome | /src/controls.rs | UTF-8 | 50,200 | 2.71875 | 3 | [] | no_license | use core::fmt::Debug;
use std::thread::JoinHandle;
use std::collections::HashMap;
use std::io::Write;
use std::path::Path;
use std::ffi::OsStr;
use std::sync::mpsc::{sync_channel, SyncSender, TrySendError, TryRecvError, Receiver};
extern crate serde_json;
use serde::{Serialize as Serialize};
// #[path = "./stdin_out.r... | true |
0a3f7be84568c52db2c07cb56ef4e758d77c08fc | Rust | mneumann/splot-rs | /src/surface2.rs | UTF-8 | 791 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::ops::RangeInclusive;
pub struct Surface2<F>
where
F: Fn((f32, f32)) -> f32,
{
pub f: F,
pub xrange: RangeInclusive<f32>,
pub yrange: RangeInclusive<f32>,
}
impl<F> Surface2<F>
where
F: Fn((f32, f32)) -> f32,
{
pub fn new(f: F) -> Self {
Self {
f,
xrange... | true |
02a01ad08eb5ce64d4800f372ace15e7af17aef6 | Rust | Jonesey13/generic_game | /src/geometry/matrix4.rs | UTF-8 | 1,750 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::fmt;
use super::{TwoDTransformable, ToRenderables};
use crate::rendering::*;
use crate::collision::{ToCollisionObjects, CollisionObject};
use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, Neg, Div};
use crate::geometry::*;
#[derive(Copy, Clone, Debug)]
pub struct Matrix4 {
pub xx: f64,
pub xy: f64,
... | true |
6a31ad757ee1074b57b72f3d30a3290a6b52a802 | Rust | ericpko/raytracer | /src/geometry/sphere.rs | UTF-8 | 3,336 | 3.125 | 3 | [
"MIT"
] | permissive | // for the capital A, B, C, in intersect
#![allow(non_snake_case)]
use nalgebra as na;
use na::{ Vector3 };
use crate::scene::{ Ray, Material };
use crate::geometry::Object;
pub struct Sphere {
pub center: Vector3<f64>,
pub radius: f64,
pub material: Material
}
impl Sphere {
pub fn new(c: &Vector3<f64... | true |
366d710764fb84210d21b5543e4ba9a8a5cd511b | Rust | CroPo/roguelike-tutorial-2018 | /part_5/src/main.rs | UTF-8 | 4,267 | 2.53125 | 3 | [
"WTFPL"
] | permissive | extern crate tcod;
extern crate rand;
mod entity;
mod render;
mod map_objects;
mod game_states;
use tcod::console::{Root, Console, Offscreen};
use tcod::FontLayout;
use tcod::FontType;
use tcod::colors;
use tcod::input::Key;
use tcod::input::KeyCode;
use tcod::map::FovAlgorithm;
use entity::Entity;
use map_objects::... | true |
588d26934907b4cc096d8f0dc55e719526090ca6 | Rust | gittysachin/Rust-Workshops | /Rust-Lang-Course/src/lifetime.rs | UTF-8 | 860 | 3.921875 | 4 | [] | no_license | struct Person {
name: String,
}
impl Person {
fn get_ref_name(&self) -> &String {
&self.name
}
}
struct Company<'z> {
// lets have the name of lifetime = z
name: String,
ceo: &'z Person,
}
fn lifetime() {
// &'static str // So essentially static is a lifetime, it's essentially a defenition of ho... | true |
05d7d659ff49ee53e694874437d31394e34543a9 | Rust | impguard/sandbox | /playground/rust/functions/src/main.rs | UTF-8 | 909 | 4.25 | 4 | [] | no_license | fn main() {
another_function(32);
let x = returning_function(2);
println!("5 * 5 is {x}");
let y = if x < 25 {
let z = 5;
z + 42
} else {
42
};
println!("y is {y}");
let mut i = 0;
'loopname: loop {
i += 1;
if i > 5 {
break 'loo... | true |
0d28d9e480a3328fa46849b5cfede934879260a8 | Rust | leizy0/AoCInRust | /2019/day10/src/bin/part1.rs | UTF-8 | 805 | 2.890625 | 3 | [
"MIT"
] | permissive | use day10::asteroid::read_map;
fn main() {
let input_path = "inputs.txt";
let asteroid_map = match read_map(input_path) {
Ok(m) => m,
Err(e) => {
eprintln!(
"Failed to read asteroid map from given input file({}), get error({})",
input_path, e
... | true |
209424208539f46bd0a224adcec48200182acbff | Rust | memoryruins/bevy_mod_picking | /src/select.rs | UTF-8 | 1,222 | 3.0625 | 3 | [
"MIT"
] | permissive | use super::*;
use bevy::prelude::*;
/// Meshes with `SelectableMesh` will have selection state managed
#[derive(Debug)]
pub struct SelectablePickMesh {
selected: bool,
}
impl SelectablePickMesh {
pub fn new() -> Self {
SelectablePickMesh::default()
}
pub fn selected(&self) -> bool {
se... | true |
2285b5e853571c7d37c56b1600279ff0a7071a46 | Rust | pnkfelix/rust-glm | /src/scalar.rs | UTF-8 | 1,359 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | // Copyright 2014 Felix S. Klock II. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// opt... | true |
12358ee0b84608bd9795d09aef1186c9eefa65da | Rust | jduan/talent-plan | /courses/rust/projects/project-2/src/error.rs | UTF-8 | 697 | 2.734375 | 3 | [
"MIT",
"CC-BY-4.0"
] | permissive | use crate::error::KvsError::{IoError, SerdeError};
use std::io;
use std::io::Error;
/// Errors that can be thrown by this program.
#[derive(Debug)]
pub enum KvsError {
/// UnexpectedEOF
UnexpectedEOF,
/// IO errors
IoError(io::Error),
/// Key not found
KeyNotFound,
/// Failed to deserial... | true |
6fe30421def20a64e862f1444cac218624f86503 | Rust | sigp/lighthouse | /crypto/bls/src/generic_aggregate_public_key.rs | UTF-8 | 1,647 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
generic_public_key::{GenericPublicKey, TPublicKey},
Error,
};
use std::fmt::{self, Debug};
use std::marker::PhantomData;
/// Implemented on some struct from a BLS library so it may be used internally in this crate.
pub trait TAggregatePublicKey<Pub>: Sized + Clone {
fn to_public_key(&self) -> ... | true |
e54eca626f9b9d7a9b07565debc70d78bfa05606 | Rust | jmarzin/milenio-api-rust | /src/a_propos.rs | UTF-8 | 1,860 | 2.625 | 3 | [] | no_license | use rocket_contrib::json::Json;
use std::{io, fs};
use serde_json::Value;
use std::path::Path;
use crate::BASE;
use std::fs::File;
use std::io::{BufReader, Write};
use crate::tools::Administrateur;
use crate::realisations::Photo;
#[get("/a_propos")]
pub fn get_a_propos() -> Result<Json<Value>, io::Error> {
let pat... | true |
cc88a516e4b15999e21c8e9581a9cb96baf7882a | Rust | uuhan/yata | /src/core/action.rs | UTF-8 | 11,093 | 3.578125 | 4 | [
"Apache-2.0"
] | permissive | use crate::core::ValueType;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::fmt;
use std::ops::{Neg, Sub};
type SignalType = u8;
const BOUND: SignalType = SignalType::MAX;
const BOUND_FLOAT: f64 = BOUND as f64;
/// Action is basic type of Indicator's signals
///
/// It may be positive \(means ... | true |
9f399679e80fc3f397973c2c3f372475f0c999bb | Rust | flyingcircusio/fc-nixos | /pkgs/fc/roundcube-chpasswd/src/main.rs | UTF-8 | 6,738 | 2.75 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
use anyhow::{bail, ensure, Context, Result};
use clap::{app_from_crate, Arg};
use env_logger::{Builder, Env};
use fs2::FileExt;
use log::{error, info, warn};
use pwhash::sha256_crypt;
use std::fmt;
use std::fs::OpenOptions;
use std::io::{prelude::*, stdin, SeekFrom};
use std::path::Path... | true |
6921b06d3adeef8f69710ec630bfdc0b423012e0 | Rust | atanmarko/yatima | /src/main.rs | UTF-8 | 1,788 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::{
fs,
path::PathBuf,
};
use structopt::StructOpt;
use yatima::{
core,
hashspace,
parse,
repl,
};
#[derive(Debug, StructOpt)]
#[structopt(about = "A programming language for the decentralized web")]
enum Cli {
Save {
#[structopt(parse(from_os_str))]
input: PathBuf,
},
Show {
inpu... | true |
45d2a2fc5e7f2721382782745376896ef8a24f22 | Rust | anderspitman/messend-talk | /demo/rust/src/bin/client.rs | UTF-8 | 316 | 2.765625 | 3 | [] | no_license | use std::str;
fn main() {
let mut peer = messend::initiate("127.0.0.1", 9001);
peer.send_message("Hi there from Rust client".as_bytes());
let message = peer.receive_message_wait().expect("message unwrap failed");
println!("Server responded: {:?}", str::from_utf8(&message).expect("parse bytes"));
}
| true |
074ec8b6069bbba07378f2e57af03e8c98f5698d | Rust | cjkenn/tank | /src/syntax/ast.rs | UTF-8 | 1,109 | 3.5 | 4 | [] | no_license | #[derive(Debug, PartialEq, Clone)]
pub enum AstType {
Template,
Element,
Ident,
ElementName,
Contents,
Number,
AttrList,
IfExpr,
ForExpr,
AssignExpr,
VariableValue,
Include,
Plus,
Minus,
EqualsEquals,
Gt,
Lt,
GtEquals,
LtEquals,
NotEquals,
... | true |
3520d4d0b77cf9d72deb3e957a5284bcc694c3ff | Rust | sogapalag/contest | /comm/datastr/dfa.rs | UTF-8 | 2,880 | 3.078125 | 3 | [] | no_license | // ref: https://kuretchi.github.io/blog/entries/automaton-dp/
/// An (almost) DFA. trans is allowed to return None.
/// S: alphabet (the set consisting of letters)
trait DFA<S> {
fn size(&self) -> usize;
fn trans(&self, state: usize, char: S) -> Option<usize>;
fn init(&self) -> Vec<usize>;
fn is_final_s... | true |
36ad96ebb01caad4c347ef840acb7e8778365fde | Rust | bauhaus93/world-gen | /core/src/file/file_error.rs | UTF-8 | 609 | 2.71875 | 3 | [] | no_license | use std::io;
use std::num;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum FileError {
#[error("io: {source}")]
IO {
#[from]
source: io::Error,
},
#[error("invalid path: {0}")]
InvalidPath(String),
#[error("parse float: {source}")]
ParseFloat {
#[from]
... | true |
f8476b90832cccce496974a2f73d9ff480b3c94e | Rust | nuta/archives | /resea2/libs/collections/linked_list.rs | UTF-8 | 12,845 | 2.984375 | 3 | [] | no_license | //! An intrusive linked list.
//!
//! ```ignore
//! use intrusive::{define_list_node, linked_list::{List, ListLink}};
//! use std::sync::Arc;
//!
//! struct Thread {
//! id: usize,
//! link: ListLink<ThreadsNode>,
//! }
//!
//! define_list_node!(ThreadsNode, Arc<Thread>, link);
//!
//! let mut threads = List::<... | true |
7d99b395e707ae71bb08e80c1239981cba52f679 | Rust | storiqaamericanteam/Autotests | /functional-tests/src/query/delete_delivery_company.rs | UTF-8 | 1,300 | 2.59375 | 3 | [] | no_license | use failure::Error as FailureError;
use graphql_client::GraphQLQuery;
use graphql_client::Response;
use request::GraphqlRequest;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/queries/delete_delivery_company.graphql"
)]
pub struct DeleteCompanyMutation;
pub use ... | true |
0dc68e596efd8576a29f8c8db7fd5ec173c1f018 | Rust | Smithay/smithay | /smithay-drm-extras/build.rs | UTF-8 | 1,710 | 2.625 | 3 | [
"MIT"
] | permissive | fn main() {
#[cfg(feature = "generate-hwdata")]
generate_hwdata();
}
#[cfg(feature = "generate-hwdata")]
fn generate_hwdata() {
use std::{
fs,
path::{Path, PathBuf},
};
let pkg_path = pkg_config::get_variable("hwdata", "pkgdatadir");
// Old versions of hwdata don't have .pc fil... | true |
9c16afab1a32bf28410429f8ce21acb219f1ceb9 | Rust | gijs-s/pointctl | /src/exp/mod.rs | UTF-8 | 2,922 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Module containing the explanation mechanisms used for the visualization.
// Sub modules
mod da_silva;
mod driel;
mod explanation;
mod normal;
// Re-export the public facing parts of this module
pub use self::{
da_silva::{DaSilvaExplanation, DaSilvaType},
driel::{VanDrielExplanation, VanDrielType},
nor... | true |
786cb55a6b3fc08f7f03afce668bc02d51198242 | Rust | wictory/rust_presentation_source | /map_over_list.rs | UTF-8 | 617 | 3.578125 | 4 | [] | no_license |
fn main() {
// Create an iterator counting from 0 to 10.
let a = range(0, 10);
// Create an iterator which contains the double of each
// element in a.
let the_double = a.map(|x| { x * 2 });
// Zip together the_double with an infinite sequence
// of increasing numbers.
let mut b = the_... | true |
c82fb3efb094823708f4ef4b3827b153233c18d8 | Rust | Revertron/hermes | /src/dns/utils.rs | UTF-8 | 341 | 2.515625 | 3 | [] | no_license | extern crate time;
use std::thread;
pub fn current_time_millis() -> u64 { time::precise_time_ns() / 1000000 }
pub fn current_thread_name() -> String {
match thread::current().name() {
Some(name) => {
name.to_owned()
},
None => {
format!("{:?}", thread::current().id... | true |
149b93040bd45f37391a05fffd4d96374f2cb372 | Rust | bastill/MalwareDevSeries | /Day 4 and 5/xorcrypt/src/lib.rs | UTF-8 | 1,454 | 3.09375 | 3 | [] | no_license | use proc_macro::TokenStream;
#[proc_macro]
pub fn prepare_encryption(_tokens: TokenStream) -> TokenStream {
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
let key =
String::from_utf8(thread_rng().sample_iter(&Alphanumeric).take(20).collect()).unwrap();
std::env::set_var("EN... | true |
f1ce40c2e179309244a2e79ae84b59a35fef2f9e | Rust | abonander/rust-image | /src/png/zlib.rs | UTF-8 | 2,535 | 2.921875 | 3 | [
"MIT"
] | permissive | //! An Implementation of RFC 1950
//!
//! Decoding of zlib compressed streams.
//!
//! # Related Links
//! *http://tools.ietf.org/html/rfc1950 - ZLIB Compressed Data Format Specification
use std::old_io;
use std::old_io::IoResult;
use super::hash::Adler32;
use super::deflate::Inflater;
enum ZlibState {
Start,
... | true |
a2665114cb9ae242be0003fb48c500b27218e00b | Rust | sgrif/rust-dotenv | /src/lib.rs | UTF-8 | 6,734 | 3.421875 | 3 | [
"MIT"
] | permissive | //! This crate provides a configuration loader in the style of the [ruby dotenv
//! gem](https://github.com/bkeepers/dotenv). This library is meant to be used
//! on development or testing environments in which setting environment
//! variables is not practical. It loads environment variables from a .env
//! file, if a... | true |
b7467cce188498b805ddc5cab4251a17b799e537 | Rust | Steelbirdy/poise | /src/framework/mod.rs | UTF-8 | 13,577 | 2.8125 | 3 | [
"MIT"
] | permissive | //! The central Framework struct that ties everything together.
// Prefix and slash specific implementation details
mod prefix;
mod slash;
mod builder;
pub use builder::*;
use crate::serenity::client::{bridge::gateway::ShardManager, Client};
use crate::serenity_prelude as serenity;
use crate::*;
pub use prefix::di... | true |
4db5c6423215c0b7b4549dfd0683d4923ffad0ef | Rust | 1kasu/gpeli | /src/silmukka/saannollinensilmukka.rs | UTF-8 | 4,522 | 2.59375 | 3 | [] | no_license | extern crate sdl2;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use std::time::{Duration, Instant};
use super::Paasilmukka;
use crate::maailma::*;
use crate::paivitys::*;
use crate::piirtaja::*;
use crate::syotteet::*;
/// Pääsilmukka, joka päivittää pelin tilaa säännöllisin väliajoin
pub struct... | true |
d6f93c214630bb21d74a7084cfab0658c29ed7cf | Rust | BYOND/byond-rs | /lib/crc32/src/lib.rs | UTF-8 | 4,819 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! ## Example
//!
//! ```rust
//! use byond_crc32::Crc32;
//!
//! let mut crc32 = Crc32::new();
//! crc32.update(b"123456789");
//! let checksum = crc32.as_u32();
//! ```
#![cfg_attr(not(any(feature = "std", test)), no_std)]
mod combine;
mod tables;
#[cfg(not(feature = "std"))]
use core::{convert::TryInto, hash::Ha... | true |
5cfbb47faf7f00b21b454966015a82d4b044bc9b | Rust | EFanZh/LeetCode | /src/problem_0576_out_of_boundary_paths/dynamic_programming.rs | UTF-8 | 2,272 | 2.96875 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::mem;
impl Solution {
fn abs_diff(lhs: usize, rhs: usize) -> usize {
if lhs < rhs {
rhs - lhs
} else {
lhs - rhs
}
... | true |
07a18a195ddf95dc4c6e9edb07790a1829ba15b6 | Rust | hwchen/manx-rs | /src/executor.rs | UTF-8 | 1,450 | 2.9375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! It's multitask's work-stealing executor, but just running on its own single thread
//!
//! Taken from the smol lib, which hasn't it's new architecture yet.
//!
//! Not sure how I can just use the LocalExecutor? Maybe can't if I want to keep the executor on a
//! background thread.
use once_cell::sync::Lazy;
use mu... | true |
dc9841d07cfddd370e124a5176b542bab311e51b | Rust | jonathanstrong/termion | /examples/async.rs | UTF-8 | 1,325 | 2.828125 | 3 | [
"MIT"
] | permissive | extern crate termion;
use termion::raw::IntoRawMode;
use termion::async_stdin;
use std::io::{Read, Write, stdout};
use std::thread;
use std::time::Duration;
fn main() {
let stdout = stdout();
let mut stdout = stdout.lock().into_raw_mode().unwrap();
let mut stdin = async_stdin().bytes();
write!(stdout... | true |
ba9b24a69acca21d3a122d31ff45b4403c94ca1a | Rust | angular-rust/clutter-rs | /src/auto/text.rs | UTF-8 | 74,668 | 2.828125 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | // Scriptable
use crate::{Actor, Animatable, Color, Container, Rect, TextBuffer};
use glib::{
object as gobject,
object::{Cast, IsA, ObjectExt},
signal::{connect_raw, SignalHandlerId},
translate::*,
GString, StaticType, Value,
};
use std::boxed::Box as Box_;
use std::{fmt, mem, mem::transmute};
// ... | true |
9af6c737d425dd803f76c4bd0c9d62b849e4e82a | Rust | loveyang2012/rshc | /src/util/template.rs | UTF-8 | 3,073 | 2.90625 | 3 | [
"MIT"
] | permissive | pub fn prog() -> &'static str {
r###"
use std::io;
use std::iter::repeat;
use std::io::Write;
use std::process;
use std::process::{Command, Stdio};
use std::env;
pub struct Arc4 {
i: u8,
j: u8,
state: [u8; 256],
}
impl Arc4 {
pub fn new(key: &[u8]) -> Arc4 {
assert!(key.len() >= 1 && key.l... | true |
badaada6d3f9522301386960cf21f2bec15f979a | Rust | siku2/yew-playground | /frontend/src/boot.rs | UTF-8 | 1,908 | 2.640625 | 3 | [] | no_license | use crate::{
routes::AppRouter,
services::locale::{self, LoadBundleTask},
};
use yew::{html, Component, ComponentLink, Html, ShouldRender};
#[derive(Debug)]
pub struct Root;
impl Component for Root {
type Message = ();
type Properties = ();
fn create(_props: Self::Properties, _link: ComponentLink<... | true |
3e8bae015ac71d34ca3a10e422cb9b3607a52f90 | Rust | CyberFlameGO/stork | /src/index_versions/v3/structs.rs | UTF-8 | 6,042 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use super::scores::MATCHED_WORD_SCORE;
use crate::config::TitleBoost;
use crate::{
common::{Fields, InternalWordAnnotation},
config::OutputConfig,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
pub type EntryIndex = usize;
pub type AliasTarget = String;
pub type Score = u8;
/**
* A se... | true |
c06bcabe23ed06d6e7b2d0cb57ba17147c73cdaa | Rust | rlecaro2/rutilities | /src/utilities/clean.rs | UTF-8 | 1,653 | 3.828125 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use regex::Regex;
use wasm_bindgen::prelude::wasm_bindgen;
/// Clean a formatted rut (or with anything, really) to keep only the significant characters.
/// Useful for internal representations and validating.
/// ```rust
/// use rutilities::clean_rut;
///
/// fn main() {
/// let rut = "12.345.678-9";
/// let clean... | true |
c6c485eeb59e6dc8e8356d074d1aec24615284cb | Rust | shadow/shadow | /src/lib/vasi-sync/tests/lazylock-tests.rs | UTF-8 | 2,823 | 3.21875 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | //! This file contains tests intended to be run using [loom]. See the
//! [crate-level documentation](crate) for details about running these under
//! loom.
//!
//! [loom]: <https://docs.rs/loom/latest/loom/>
mod sync;
mod lazylock_tests {
use super::sync;
use vasi_sync::lazy_lock::LazyLock;
#[test]
... | true |
e118360bd637eb7864cad0bae955a6b000b23398 | Rust | shadow/shadow | /src/lib/shadow-shim-helper-rs/src/util/time.rs | UTF-8 | 3,086 | 3.6875 | 4 | [
"LicenseRef-scancode-public-domain"
] | permissive | /// Helper for formatting times.
#[derive(Debug, Eq, PartialEq)]
pub struct TimeParts {
pub hours: u32,
pub mins: u32,
pub secs: u64,
pub nanos: u64,
}
impl TimeParts {
pub fn from_nanos(total_nanos: u128) -> Self {
// Total number of integer seconds.
let whole_secs = u64::try_from(... | true |
a614e7b187aad9cd0ad9f3037ca353e5867716dc | Rust | cessen/ropey | /benches/remove.rs | UTF-8 | 7,121 | 2.921875 | 3 | [
"MIT"
] | permissive | extern crate criterion;
extern crate rand;
extern crate ropey;
use criterion::{criterion_group, criterion_main, Criterion};
use rand::random;
use ropey::Rope;
const TEXT: &str = include_str!("large.txt");
const TEXT_SMALL: &str = include_str!("small.txt");
fn mul_string_length(text: &str, n: usize) -> String {
l... | true |
52f3d99b76d4375179b3fbb92e68d9e722cf1ad3 | Rust | thepowersgang/rust_os | /Usermode/libsyscalls/threads.rs | UTF-8 | 6,004 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | //
//
//
//! Thread management system calls
#[derive(Debug)]
pub enum RecvObjectError
{
NoObject,
ClassMismatch(u16),
}
impl ::core::fmt::Display for RecvObjectError {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self
{
&RecvObjectError::NoObject => f.write_str("No object on qu... | true |
e9bb775fba5b14c58d9d819d7be04a689732185e | Rust | takashi4233/rust | /slice/src/main.rs | UTF-8 | 402 | 3.546875 | 4 | [] | no_license | fn main() {
let mut s = String::from("hoge1 hoge2 hoge3");
let word = first_word(&s);
println!("word:{},s:{}",word,s);
let hello = &s[0..5];
println!("{}",hello);
s.clear();
println!("word:{},s:{}",word,s);
}
fn first_word(s:&String) -> usize {
let bytes = s.as_bytes();
for (i,&item) in byte... | true |
1d8c950713655c7fb09c1e8819966948c661bb69 | Rust | chamons/ArenaGS | /src/core/physics.rs | UTF-8 | 3,342 | 3.125 | 3 | [] | permissive | use bevy_ecs::prelude::*;
use super::{find_player, Character, Map, Point, Position};
pub fn is_area_clear_of_others(world: &mut World, area: &[Point], invoker: Option<Entity>) -> bool {
world.resource_scope(|world, map: Mut<Map>| {
let mut query = world.query_filtered::<(Entity, &Position), With<Character... | true |
7f61f081221bcd5d498c3a4a9fbfd6c6c7385eaa | Rust | hollg/ray-tracer | /src/shapes/sphere.rs | UTF-8 | 8,169 | 3.40625 | 3 | [] | no_license | use crate::intersection::*;
use crate::material::Material;
use crate::matrix::*;
use crate::object::Object;
use crate::ray::*;
use crate::tuple::*;
use uuid::Uuid;
#[derive(PartialEq)]
pub struct Sphere {
transform: Matrix,
pub material: Material,
inverse: Matrix,
id: Uuid,
}
impl Sphere {
pub fn ... | true |
66ec3b6e2e8b6dd29e65c098730a8dc8d8d10675 | Rust | goldencm/CardGameSuite | /player/src/lib.rs | UTF-8 | 1,554 | 3.46875 | 3 | [] | no_license |
//! # Player Library
//!
//! 'player' library is used to contstruct individual player
//! objects for games
extern crate cards_lib as lib;
use lib::card::*;
use lib::deck::*;
/// Logic fields for the player
#[derive(Debug)]
pub struct Player {
pub player_id : u32,
pub cards : Deck,
score : u32,
}
im... | true |
29f8fc6901262a24f5cabd43c055e61334db7be6 | Rust | mlabrenz117/advent_of_code | /aoc_2018/src/day_1.rs | UTF-8 | 669 | 3.25 | 3 | [] | no_license | use std::collections::HashSet;
#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<i64> {
input
.lines()
.filter_map(|l| l.parse::<i64>().ok())
.collect()
}
#[aoc(day1, part1)]
pub fn one(input: &[i64]) -> i64 {
input.iter().sum()
}
#[aoc(day1, part2)]
pub fn two(input: ... | true |
e1043f8c3ffe3a47ce187a80d94cc056c6b9849d | Rust | bramhaag/lord-bucket-bot | /src/main.rs | UTF-8 | 4,795 | 2.734375 | 3 | [] | no_license | #[macro_use] extern crate serenity;
extern crate clap;
extern crate regex;
#[macro_use] extern crate lazy_static;
extern crate typemap;
use serenity::client::{Client, Context};
use serenity::model::{Message, Member};
use clap::{Arg, App};
use regex::Regex;
use typemap::Key;
type List = Vec<u64>;
struct Channels;
str... | true |
e2c7da878a02d937932549e488a546ce865ba040 | Rust | isgasho/doh-client | /src/dns.rs | UTF-8 | 6,792 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | use std::io;
use std::io::Error;
use std::net;
use std::net::SocketAddr;
use std::fmt::{Display, Formatter};
use futures::stream::{SplitSink, SplitStream};
use futures::Stream;
use tokio::reactor::Handle;
use tokio::codec::{Decoder, Encoder};
use tokio::net::{UdpSocket, UdpFramed};
use bytes::{Bytes, BytesMut};
#[... | true |
880ad54463ba6662c994f979009d9614d578b38b | Rust | dtynn/learning | /leetcode-rs/p0078_subsets/src/lib.rs | UTF-8 | 973 | 3.265625 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn subsets(nums: Vec<i32>) -> Vec<Vec<i32>> {
let mut result = vec![vec![]];
let prefix = vec![];
Solution::traverse(&mut result, &prefix, &nums[..]);
result
}
fn traverse(result: &mut Vec<Vec<i32>>, prefix: &[i32], remains: &[i32]) ... | true |
92e0a68d9ab768e75ce5b757ac89d4aaa928fad1 | Rust | lostinblue/diosix | /platform/x86/src/interrupts.rs | UTF-8 | 6,297 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
* diosix microkernel 'menchi'
*
* Handle interrupts for x86 systems
*
* Maintainer: Chris Williams (diosix.org)
*
*/
use ::hardware::swis;
use ::hardware::pic;
use ::hardware::exceptions;
use errors::KernelInternalError;
const MAX_IDT_ENTRY: usize = 255;
/* define flags in the IDT entries */
const INT_GATE... | true |
734fa1b8d50486713cba87e05b8da3a689df5ebf | Rust | aykevl/domo-rpi | /src/main.rs | UTF-8 | 13,538 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive |
use std::{env, fs, io, process, thread, time};
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver};
extern crate chrono;
extern crate crc8;
extern crate env_logger;
extern crate serde_json;
extern crate spidev;
extern crate ws;
mod peripheral;
mod messages;
mod socket;
use peripheral::*;
u... | true |
e93752f48ccdc07b552b19175273c61fad8270e5 | Rust | victorminden/orangutan | /src/compiler/compiler_test.rs | UTF-8 | 30,062 | 3.140625 | 3 | [] | no_license | use super::*;
use crate::ast::Program;
use crate::code::{disassemble, CompiledFunction, Constant, OpCode};
use crate::lexer::Lexer;
use crate::parser::Parser;
struct TestCase<'a> {
input: &'a str,
expected_constants: Vec<Constant>,
expected_instructions: Vec<Instructions>,
}
fn parse(input: &str) -> Prog... | true |
9946a09ed3e15deb2d0dc3df520814781f0720d6 | Rust | thevenice/senswap-contract | /program/src/helper/pubutil.rs | UTF-8 | 335 | 2.765625 | 3 | [
"MIT"
] | permissive | use solana_program::pubkey::Pubkey;
pub trait Boolean {
fn xor(&self, pk: &Pubkey) -> Self;
}
impl Boolean for Pubkey {
fn xor(&self, pk: &Pubkey) -> Self {
let a: [u8; 32] = self.to_bytes();
let b: [u8; 32] = pk.to_bytes();
let c: [u8; 32] = a.zip(b).map(|(x, y)| x ^ y);
return Pubkey::new_from_a... | true |
26051fad43dfa3c73bee6c04e23f2457fa5e0acb | Rust | SrimantaBarua/rype | /src/error.rs | UTF-8 | 1,842 | 3.1875 | 3 | [
"MIT"
] | permissive | //! Errors within `rype`
// (C) 2019 Srimanta Barua <srimanta.barua1@gmail.com>
/// `rype`'s Result type
pub type Result<T> = std::result::Result<T, Error>;
/// Errors within `rype`
#[derive(Debug)]
pub enum Error {
/// IO errors (reading files, etc.)
Io(std::io::Error),
/// Invalid font file
Invalid,... | true |
64cbcae3a968bd4ac22b8725b93839452b45016d | Rust | cmann3/stax | /src/compare.rs | UTF-8 | 2,363 | 3.171875 | 3 | [
"MIT"
] | permissive | /* compare.rs
* ---------- */
use crate::code::BoolOp;
use crate::code::BoolOp::*;
use crate::words::Word;
type BoolResult = Result<Word, String>;
pub fn do_compare(op: BoolOp, lhs: Word, rhs: Word) -> BoolResult {
match lhs {
Word::Int(l) => { return do_int(l, rhs, op) },
Word::Num(l) => { return do_num(l, r... | true |
b780dfc410d0c2e59e81c0ea2c56db78b73a6f62 | Rust | dmitry-pechersky/algorithms | /leetcode/43_Multiply_Strings.rs | UTF-8 | 1,214 | 3.53125 | 4 | [] | no_license | struct Solution {}
impl Solution {
pub fn multiply(num1: String, num2: String) -> String {
let num1 = num1.as_bytes().iter().rev().map(|v| v - 48).collect::<Vec<u8>>();
let num2 = num2.as_bytes().iter().rev().map(|v| v - 48).collect::<Vec<u8>>();
let (n1, n2) = (num1.len(), num2.len());
... | true |
ef1e691b3978887dd6e42ae9dc3442f89990055e | Rust | SunDoge/leetcode-rust | /src/bin/70-climbing-stairs.rs | UTF-8 | 306 | 3.203125 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn climb_stairs(n: i32) -> i32 {
let s = 5_f64.sqrt();
let res = (((1. + s) / 2.).powi(n + 1) - ((1. - s) / 2.).powi(n + 1)) / s;
res.round() as i32
}
}
fn main() {
let input = 3;
assert_eq!(3, Solution::climb_stairs(input));
} | true |
ef769f8eba0343fbe6d3d19484ed1309283daca3 | Rust | nilq/ketchup | /src/language/vm/mod.rs | UTF-8 | 5,448 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
pub mod value;
pub mod op;
#[macro_use]
pub mod object;
pub use self::value::Value;
pub use self::op::Op;
pub use self::object::*;
macro_rules! binary_op {
($vm_ref:expr, $a:ident, $b:ident, $r:expr) => {
{ let $b = $vm_ref.stack.pop().unwrap();
let $a = $vm_ref.... | true |
e42e635bf60761c1d53d244bd8f6000e93f3522d | Rust | lenko-d/pine-tree-tax | /src/main.rs | UTF-8 | 10,878 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate clap;
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate lazy_static;
extern crate serde;
extern crate chrono;
mod account;
mod conversions;
mod tax;
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::hash::Hash;
use std::io;
use chrono::Duration;
use clap::{Ap... | true |
d4c5aef9f1f2556d603524a04a5bc555498df448 | Rust | benmtz/npm-resource | /apps/npm-resource/src/bin/in.rs | UTF-8 | 1,087 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
env,
io::{self, Read},
};
use npm_resource::npm::registry_client::RegistryClient;
use npm_resource::resource::resource::Payload;
use serde_json::json;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::init();
// A resource type receive as $1 a path and config as stdin
... | true |
6305a720bc60167478644a1d01857681d5423bbc | Rust | ToneyWang/wx-sdk | /src/cache.rs | UTF-8 | 2,374 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use tokio::sync::RwLock;
use std::hash::Hash;
use std::time::{Duration, Instant};
#[derive(Clone)]
pub struct Item<T> {
pub object: T,
expiry: Option<Instant>,
}
impl<T> Item<T> {
// Creates a new cache item.
pub fn new(object: T, item_duration: Option<Duration>) -> Sel... | true |
bc4fee168bb9d7d58f049debaf8b54557831439d | Rust | Hoverbear/digitalocean | /src/client/reqwest.rs | UTF-8 | 5,349 | 2.890625 | 3 | [
"MIT"
] | permissive | pub use reqwest::Client;
use crate::api::{HasPagination, HasResponse, HasValue, MAX_PER_PAGE};
use crate::error::Error;
use crate::method::{Create, Delete, Get, List, Update};
use crate::request::Request;
use crate::DigitalOcean;
use log::info;
use reqwest::StatusCode;
use reqwest::{RequestBuilder, Response};
impl Di... | true |
d5daceff3dfd4aa733cf9d72caf73d643c05746b | Rust | sueken5/resea | /libs/resea/lib.rs | UTF-8 | 3,387 | 2.546875 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | //! # Resea Standard Library
//!
//! Resea Standard Library provides essential features including:
//!
//! - Language primitives and core features: [`RefCell<T>`], [`Rc<T>`], [`Option<T>`], etc.
//! - Collections: [`Vec<T>`], [`VecDeque<T>`], [`HashMap<K, V>`], etc.
//! - Resea-specific primitives: [`Channel`], [`Mes... | true |
0523dda7cf41bd1235cef0966caf534428766e04 | Rust | octaplexsys/event-service | /src/app.rs | UTF-8 | 1,433 | 2.96875 | 3 | [] | no_license | use anyhow::Result;
use log::info;
use crate::kafka::event_queue::EventQueue;
use crate::{grpc, kafka};
#[derive(Deserialize, Debug, Clone, PartialEq)]
pub struct AppConfig {
pub kafka: kafka::KafkaConfig,
pub grpc: grpc::GrpcConfig,
}
/// Starts server for processing Grpc/Rest events. Connects and writes ev... | true |
6ffe9dbcb489b088f45bd9cd7d932e351b1d1bb9 | Rust | axos88/lpc-pac | /lpc11u6x/src/adc/chan_thrsel.rs | UTF-8 | 22,199 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::CHAN_THRSEL {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `CH0_THRSEL`"]
#[... | true |
b615c6a31961086ee1a23895381b8cea0f323c94 | Rust | Juzley/adventofcode2019 | /intcode/src/lib.rs | UTF-8 | 13,544 | 3.203125 | 3 | [] | no_license | use std::fs::File;
use std::io;
use std::io::{BufRead, BufReader};
const OPCODE_ADD: i8 = 1;
const OPCODE_MUL: i8 = 2;
const OPCODE_IN: i8 = 3;
const OPCODE_OUT: i8 = 4;
const OPCODE_JIT: i8 = 5;
const OPCODE_JIF: i8 = 6;
const OPCODE_LT: i8 = 7;
const OPCODE_EQ: i8 = 8;
const OPCODE_BASE: i8 = 9;
const OPCODE_HALT: i... | true |
1dd3df7b418c3b42845e9e4eb4cd53f6c92afd67 | Rust | lassade/bevy_spine | /src/transform/components/transform2d.rs | UTF-8 | 4,754 | 3.28125 | 3 | [] | no_license | use bevy::{math::Mat2, prelude::*};
// TODO: Tag components to mix and match 2d and 3d nodes
/// Tags the top most [`Transform2D`] entity in the hierarchy group,
/// meaning that it can also be a child of [`Transform`] and still be considered root;
///
/// Used by [`local_to_world_2d5_system`](super::super::systems::... | true |
566e079ecf222152849684826692d05d68602f87 | Rust | tesuji/chip8emu | /src/timer.rs | UTF-8 | 1,816 | 3.21875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::convert::TryFrom;
use std::time::Instant;
// In COSMAC VIP manual, this is the minimum value that the timer responds
const MIN_SOUND_DURATION: u8 = 2;
const FPS: u32 = 60;
const NANOS_PER_SECOND: u32 = 10_u32.pow(9);
const WAIT_TIME_NS: u32 = NANOS_PER_SECOND / FPS;
/// Intended to be used for timing the eve... | true |
870844b909e85ad892ef2a0581be2c11a493bdcb | Rust | h3nnn4n/The-awesomest-SNES-emulator-to-ever-have-existed | /src/snes/cpu/mod.rs | UTF-8 | 709 | 2.53125 | 3 | [
"MIT"
] | permissive | pub mod instructions;
pub mod registers;
use self::registers::Registers;
pub struct CPU {
regs: registers::Registers,
}
impl CPU {
pub fn new() -> CPU {
println!("I'm the most greatest S-CPU ever!");
CPU { regs: Registers::new() }
}
}
#[cfg_attr(rustfmt, rustfmt_skip)]
impl CPU {
pub ... | true |
fd8abb6d7d9314cf967a148e36c3c9e57170368b | Rust | qiaofengxi/solomon | /gen-rs/src/json.rs | UTF-8 | 1,048 | 3.015625 | 3 | [
"MIT"
] | permissive | use chrono::NaiveDate;
use serde::Serialize;
use serde_json::to_writer;
use std::fs::File;
use std::io::Result;
use crate::Entry;
pub fn write_summary(entries: &mut Vec<Entry<'_>>) -> Result<()> {
#[derive(Serialize)]
struct Post<'a> {
title: &'a str,
date: NaiveDate,
slug: &'a str,
... | true |
af56c30be3aed1bcc704d36875037128d48976e5 | Rust | jedhsu/mind | /src/duel/_op/flow.rs | UTF-8 | 1,283 | 2.5625 | 3 | [] | no_license | pub trait Flow {
fn tick(&self, realizing: Realizing);
fn evaluate(&self, realizing: Realizing) -> Played;
//! Compare two versions of a neural network (params::ArenaParams)
//!
//! Works for both two-player and single-player games.
fn reset(&self);
}
impl Flow for Duel {
fn tick(&self, re... | true |
579b63ecb2c3e9a6e70aac7621913f5062c73701 | Rust | 1Password/typeshare-old | /src/swift.rs | UTF-8 | 7,395 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use crate::language::{Language, Params, RustAlgebraicEnum, RustConstEnum, RustStruct};
#[derive(Default)]
pub struct Swift {}
impl Swift {
pub fn new() -> Self {
Swift {}
}
}
fn swift_type(s: &str) -> &str {
match s {
"String" => "String",
"i8" => "Int8",
... | true |
cf9c89144f4b3b7868a4daa60b17ab8db23af9af | Rust | pklazy/lpc54628-rust | /src/dma0/channel/ctlstat.rs | UTF-8 | 2,988 | 2.78125 | 3 | [] | no_license | #[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
impl super::CTLSTAT {
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `VALIDPENDING`"... | true |
24408e646096ba451c957b8efd64fe7788b5ecd0 | Rust | serejkaaa512/stripe-rs | /stripe/src/client.rs | UTF-8 | 5,661 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use error::{Error, ErrorObject, RequestError};
use reqwest;
use reqwest::RequestBuilder;
use reqwest::header::{
HeaderMap, HeaderName, HeaderValue, AUTHORIZATION,
};
use serde;
use serde_json;
use serde_qs;
use std::io::Read;
#[derive(Clone, Default)]
pub struct Params {
pub stripe_account: Option<String>,
... | true |
04d89a87a7909b4361966c9ad26a1617678cd4a1 | Rust | overengineering/ThermoRustular | /src/main.rs | UTF-8 | 2,963 | 2.90625 | 3 | [] | no_license | mod api;
extern crate time;
extern crate chrono;
use std::io::{self, Write};
use chrono::prelude::*;
use time::{Tm, Duration};
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() {
let mut last_launch: Option<Tm> = match File::open("last_launch.txt") {
Ok(f) => {
let... | true |
b38e0dd38e3d3f6e267798fc19ba51ec04a4a05e | Rust | etoledom/rust_practice | /06_snake/src/snake/game.rs | UTF-8 | 9,285 | 3.046875 | 3 | [] | no_license | use super::button::Button;
use super::snake::Snake;
use utilities::block::Block;
use utilities::geometry::{Direction, Point, Size};
use utilities::graphics::Color;
const FOOD_COLOR: Color = Color {
red: 0.8,
green: 0.0,
blue: 0.0,
alpha: 1.0,
};
const BORDER_COLOR: Color = Color {
red: 0.0,
gr... | true |
d0f56532f389b371cf49ff8c650d4596475bd526 | Rust | rust-chainblock/mitrid-core | /tests/app/command/response.rs | UTF-8 | 2,438 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use mitrid_core::base::Sizable;
use mitrid_core::base::Checkable;
use mitrid_core::base::Serializable;
use mitrid_core::base::Meta;
use fixture::base::Payload;
use fixture::app::command::Address;
use fixture::app::command::Response;
#[test]
fn test_response_new() {
let address = Address::default();
let meta =... | true |
733fca6997788d401680dc2700773e605b8f2ff3 | Rust | plstic/cmsc389b-fall2020 | /notes/examples/rust/loops.rs | UTF-8 | 1,089 | 4.28125 | 4 | [] | no_license |
fn main(){
//This is a for loop. Notie we did not have to create an I varaible.
//ALso notice that we use an iterator like construct as 0..4 is an
//iterator.
//
//0..4 is exclusive, while 0..=4 is iinclusive.
//
for i in 0..4{
println!("index: {}", i)
}
//Itera... | true |
8ac4597b5e5028daef9ad72c1a408d095a168e33 | Rust | fuchsnj/reminisce | /examples/mapper.rs | UTF-8 | 979 | 2.796875 | 3 | [
"MIT"
] | permissive | extern crate reminisce;
#[cfg(feature = "mappings")]
fn main() {
use reminisce::*;
let mut joysticks = scan();
let mut joystick = joysticks.pop().expect("Failed to open joystick").into_mapper();
println!("Please press the button you would like to map, then press Start to debug");
let mut button = None;
let mut ma... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.