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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
417bea783f84227072a04536b5faadcab237ebb2 | Rust | dancespiele/okspiel | /src/node/receive_screen.rs | UTF-8 | 1,661 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::{Address, AddressMessage};
use iced::{button, scrollable, Column, Element, Row, Scrollable};
pub struct ReceiveScreen {
pub addresses: Vec<Address>,
pub buttons: Vec<button::State>,
pub scroll: scrollable::State,
}
#[derive(Clone, Debug)]
pub enum Message {
AddressMsg(usize, AddressMessage)... | true |
368f30a89b7de425c866a3d6df0b43c5078f817c | Rust | mdibble/nes-emu | /src/cpu/addressing_modes.rs | UTF-8 | 6,803 | 2.921875 | 3 | [] | no_license | use crate::cpu::CPU;
impl CPU {
pub fn set_mode(&mut self, mode: Mode) -> (u16, u8) {
let address: (u16, u8) = match mode {
Mode::IMM => self.mode_imm(),
Mode::ZP => self.mode_zp(),
Mode::ZPX => self.mode_zpx(),
Mode::ZPY => self.mode_zpy(),
M... | true |
c2d9783a3dffb0cdff5bd257b5502b47f141aae6 | Rust | lukesutton/buckle | /examples/scroll_box.rs | UTF-8 | 822 | 2.75 | 3 | [
"MIT"
] | permissive | use buckle::*;
fn main() {
let layout = ScrollBox::vertical(4)
.add(Label::new("One"))
.add(Label::new("Two"))
.add(Label::new("Three"))
.add(Label::new("Four"))
.add(Label::new("Five"))
.add(Label::new("Six"))
.add(Label::new("Seven"))
.add(Label::ne... | true |
deddda234f109626c9afd0f3929e90bbf35c0673 | Rust | bramvdbogaerde/iron-auth | /src/provider.rs | UTF-8 | 459 | 2.8125 | 3 | [] | no_license | use crate::context::UserDetails;
enum ProviderStatus {
NoSuchUser,
IncorrectPassword,
NoSuchUserOrPassword
}
/// An authentication provider
/// Types that implement this can connect to a database and fetch the correct user details
/// If authentication has failed it should return a ProviderError
trait... | true |
3d1c88a3fee407dc33ddbf67c680efa4957ed1a9 | Rust | dominikdorfstetter/rust-tutorial | /src/functions.rs | UTF-8 | 677 | 3.875 | 4 | [
"MIT"
] | permissive | /**
* @author Dominik Dorfstetter
*
* Functions
**/
pub fn run() {
say_hello("Holà", "Roberta");
let get_sum = add(12, 23);
println!("The sum of 12 and 23 is {}", get_sum);
// Closure Function
// can use outside variables in the same scope
let n3 = 10;
let add_nums = |n1: i32, n2: i32... | true |
17fecf0d21b35c668272b5b5c083b0aede7d82f0 | Rust | hukumka/tex_atlas | /src/atlas.rs | UTF-8 | 4,563 | 3.296875 | 3 | [] | no_license | use serde::Serialize;
use std::collections::HashMap;
use std::cmp::Reverse;
#[derive(Debug, Serialize)]
pub struct Atlas {
pub textures: HashMap<String, Rect>,
pub size: Size,
}
#[derive(Debug, Serialize, Copy, Clone)]
pub struct Rect {
pub left: u32,
pub top: u32,
#[serde(flatten)]
pub size: ... | true |
f89dfe1a989ea2c413e269777a0b59ed8f35440d | Rust | Mitafr/NesEMU_rust | /src/cpu/mod.rs | UTF-8 | 54,969 | 3.03125 | 3 | [] | no_license | pub mod register;
pub mod opcode;
pub mod memory;
pub mod bus;
use crate::cpu::bus::Bus;
use crate::cpu::register::*;
use crate::cpu::opcode::*;
use crate::Cycle;
extern crate rand;
use rand::Rng;
use std::fmt;
#[derive(PartialEq)]
pub enum EmulationStatus {
PROCESSING,
ERROR,
BREAK,
RESET,
}
#[deri... | true |
cd56ae9442e6197ffa15062f7b74405183e9d343 | Rust | kazukiyoshida/how-linux-works | /src/bin/fork.rs | UTF-8 | 614 | 2.90625 | 3 | [] | no_license | use nix::unistd::{fork, ForkResult};
use std::process;
// fork() によって、同じプログラムの処理をもう一つのプロセスに分けて処理を続ける.
// cf. https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html
fn main() {
match unsafe { fork() }.expect("fork failed") {
ForkResult::Parent { child, .. } => {
println!(
... | true |
a63b743505358b1da9f21e25ebadbdbfccbb9944 | Rust | Zoxc/jobs | /src/cmd.rs | UTF-8 | 877 | 2.671875 | 3 | [] | no_license | use crate::Builder;
use std::io;
use std::process::{Child, Command, ExitStatus, Output};
pub struct CommandRunner<'a, 'b> {
builder: &'a Builder,
cmd: &'b mut Command,
}
impl CommandRunner<'_, '_> {
pub fn spawn(&mut self) -> io::Result<Child> {
panic!()
}
pub fn output(&mut... | true |
cd0d8662da87e59f20942d18c8f284f4561f7959 | Rust | nickray/lpc55-hal | /src/typestates/reg_proxy.rs | UTF-8 | 1,443 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use core::{
marker::PhantomData,
ops::Deref,
};
use crate::traits::reg_proxy::{
Reg,
RegCluster,
};
pub struct RegProxy<T: Reg> {
_marker: PhantomData<*const T>,
}
impl<T: Reg> RegProxy<T> {
/// Create a new proxy object
#[allow(dead_code)]
pub fn new() -> Self {
RegProxy {
... | true |
9c98732c55c6c8890cb6af76ad489ac94efc1e07 | Rust | appellation/chess | /services/api/src/routes/games/moves.rs | UTF-8 | 1,910 | 2.5625 | 3 | [] | no_license | use crate::{State, models::game::{Game, UserColor}};
use chess::{ChessMove, Color};
use serde::Deserialize;
use tide::{Request, StatusCode};
#[derive(Debug, Deserialize, Eq, PartialEq)]
#[serde(tag = "action", content = "data")]
enum MoveRequest {
MakeMove(String),
AcceptDraw,
OfferDraw,
DeclareDraw,
Resign,
}
p... | true |
f3e4c7c5b8099d118dda6d38ede0dd7749274e40 | Rust | luisnuxx/rust_playground | /src/scheduler/scheduler.rs | UTF-8 | 1,394 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | // Scheduler, and trait for .seconds(), .minutes(), etc.
use clokwerk::{Scheduler, TimeUnits};
// Import week days and WeekDay
use clokwerk::Interval::*;
use std::thread;
use std::time::Duration;
fn init() {
// Create a new scheduler
let mut scheduler = Scheduler::new();
// or a scheduler with a given time... | true |
844e38f4d72969b67a082ce4f02163915b309d28 | Rust | filippixavier/AoC2019 | /src/days/day6.rs | UTF-8 | 3,079 | 3.5 | 4 | [
"MIT"
] | permissive | use std::error::Error;
use std::fs;
use std::path::Path;
use std::collections::HashMap;
pub fn prepare_input(input: String) -> HashMap<String, Vec<String>> {
let nodes = input
.trim()
.split('\n')
.map(|elem| {
elem.trim()
.split(')')
.map(|part|... | true |
ddfe3e62e13f8c807cc83ca96ca85c33f24472d6 | Rust | loarabia/AdventOfCode | /2022/aoc05/src/main.rs | UTF-8 | 4,040 | 3.234375 | 3 | [] | no_license | use std::fs::{read_to_string};
use std::str;
use lazy_static::lazy_static;
use regex::Regex;
fn main() {
let input = read_to_string("input.txt").expect("Couldn't read input.text");
println!("{}", part1(&input));
println!("{}", part2(&input));
}
fn read_stacks(input:&str) -> Vec<Vec<u8>>{
let mut sta... | true |
bc1d1e0d854eea1884e36c1bd974b41b26c0bb08 | Rust | NorbertBodziony/matching_engine | /engine/src/bin/testrun.rs | UTF-8 | 1,703 | 3.359375 | 3 | [] | no_license | use engine::state::State;
fn main() {
let mut engine_state = State::new();
let items = 10;
for n in 0..items {
engine_state.offer_side.add_order(10 - n, 100 - n, 0);
}
for n in 0..items {
engine_state.bid_side.add_order(10 - n, 80 + n, 0);
}
for n in 1..10 {
match n... | true |
31e00fdbf64a79537b26532195965be5b66da419 | Rust | Golodnyi/flex-viewer | /src/flex/src/flex.rs | UTF-8 | 1,366 | 2.625 | 3 | [] | no_license | extern crate bitreader;
extern crate serde_json;
use self::bitreader::BitReader;
use bitfield::Bitfield;
use std::io;
static FLEX_CONFIG: &'static str = include_str!("../../../bitfield.json");
#[derive(Serialize, Deserialize)]
struct Config {
name: String,
size: u8,
character: u8,
}
lazy_static! {
s... | true |
75ca2a04d3ebd32f1aac704ad7311a64e250de72 | Rust | uazu/stakker_mio | /src/miopoll.rs | UTF-8 | 11,321 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::mio::event::{Event, Source};
use crate::mio::{Events, Interest, Poll, Token, Waker};
use slab::Slab;
use stakker::{fwd_nop, Fwd, Stakker};
use std::cell::RefCell;
use std::io::{Error, ErrorKind, Result};
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use std::sync::Arc;
use std::time::Duration;
const WAK... | true |
ad1706699039eeeee492b33db9d6d6eb2ce49d1f | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc243/src/bin/c.rs | UTF-8 | 616 | 2.953125 | 3 | [] | no_license | use std::collections::HashMap;
use proconio::{input, marker::Chars};
fn main() {
input! {
n: usize,
xy: [(i64, i64); n],
s: Chars,
};
let mut ys = HashMap::new();
for (i, (x, y)) in xy.iter().copied().enumerate() {
let entry = ys.entry(y).or_insert((1_000_000_001, -1));... | true |
95a6e91063e9a031545aa4fbdbcc34e825efcea1 | Rust | atNightly/TDN | /src/rpc.rs | UTF-8 | 4,098 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod http;
mod ws;
use smol::{
channel::{self, Receiver, Sender},
future,
net::TcpListener,
};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::path::PathBuf;
use tdn_types::{
message::{ReceiveMessage, RpcSendMessage},
primitive::Result,
rpc::RpcParam,
};
pub struct RpcConfig ... | true |
02c1b295aff5e471a967f30e7d7cbe46d6914391 | Rust | yancouto/competitive-programming | /ojs/cf/1718A.rs | UTF-8 | 951 | 2.90625 | 3 | [] | no_license | use std::io::BufRead;
use std::collections::*;
fn main() {
let mut lines = std::io::stdin().lock().lines();
let t: usize = lines.next().unwrap().unwrap().parse().unwrap();
for _ in 0..t {
let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
let arr: Vec<usize> = lines.next().unwr... | true |
6bef0c5f28cb609e8269b4604177c971289a5c03 | Rust | blackspotbear/rtnw-rs | /src/rt/renderer/aabb.rs | UTF-8 | 1,452 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate cgmath;
use cgmath::Vector3;
use cgmath::vec3;
use super::ray::Ray;
#[derive(Copy, Clone)]
pub struct AABB {
pub min: Vector3<f32>,
pub max: Vector3<f32>
}
impl AABB {
pub fn new(a: Vector3<f32>, b: Vector3<f32>) -> Self {
AABB { min: a, max: b }
}
pub fn min(&self) -> Vecto... | true |
92cedcaf0147b8e600d873c708f460fc057c171f | Rust | iansharkey/hellomoon | /luaval.rs | UTF-8 | 4,272 | 2.546875 | 3 | [] | no_license |
pub mod luaval {
use core::hashmap::linear;
use core::ops::*;
use core::to_bytes::*;
#[deriving(Eq)]
pub enum Instr {
IEq(int, int, int),
ILt(int, int, int),
ILe(int, int, int),
ITest(int, int),
ITestSet(int, int, int),
INot(int, int),
IUnm(int, int),
IAdd(int, int, int),
ISub(int, int, int),
IMul(in... | true |
cda6d852ff701631ed5d6533668d26e888e9c05b | Rust | GirkovArpa/sciter-rust-hello-world | /src/main.rs | UTF-8 | 996 | 3.078125 | 3 | [
"Unlicense"
] | permissive | // uncomment the line below to hide the console window
// #![windows_subsystem="windows"]
#[macro_use]
extern crate sciter;
use sciter::Value;
use std::env;
struct EventHandler;
impl EventHandler {
fn hello(&self, input: String) -> Value {
println!("Recieved the string: {}", input);
Value::from(format!("Hello ... | true |
6ffc03022d6126e6587443f9b37235f0bbf208b3 | Rust | matthew-mcallister/playstation-emulator | /src/cpu/exception.rs | UTF-8 | 1,192 | 3.453125 | 3 | [] | no_license | use std::fmt::*;
/// Exception types (as stored in the 'CAUSE' register)
pub enum Exception {
/// Interrupt Request
Interrupt = 0x0,
/// Address error on load
LoadAddressError = 0x4,
/// Address error on store
StoreAddressError = 0x5,
/// System call (caused by the SYSCALL opcode)
SysCa... | true |
3a8d330837d720ac8fba9df4b0c1aed64e12c524 | Rust | jeremyandrews/goose | /src/throttle.rs | UTF-8 | 2,909 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | use tokio::time;
use crate::util;
/// This throttle thread limits the maximum number of requests that can be made across
/// all GooseUser threads. When enabled, GooseUser threads must add a token to the
/// bounded channel before making a request, and this thread limits how frequently
/// tokens are removed thereby ... | true |
37b76dbc2e2d82c2a559cdcceff48664ff4093ef | Rust | JonCooperWorks/wiretap | /xtask/src/build_ebpf.rs | UTF-8 | 1,517 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use std::process::Command;
use structopt::StructOpt;
#[derive(Debug, Copy, Clone)]
pub enum Architecture {
BpfEl,
BpfEb,
}
impl std::str::FromStr for Architecture {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"bpfel-un... | true |
fa3bcb702639e881e1aa44122772f776a236f95d | Rust | XOSplicer/codingame-solutions | /puzzles/easy/mime-types.rs | UTF-8 | 2,669 | 2.953125 | 3 | [] | no_license | use std::io;
use std::collections::HashMap;
macro_rules! print_err {
($($arg:tt)*) => (
{
use std::io::Write;
writeln!(&mut ::std::io::stderr(), $($arg)*).ok();
}
)
}
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
/**
* Auto... | true |
35dee25c9f8813f6e8b4a743e8a943afbea56d27 | Rust | russellb23/dicty | /src/main.rs | UTF-8 | 2,907 | 3.078125 | 3 | [] | no_license | // CLI utility to fetch meaning from https://www.thefreedictionary.com
// Developer: Russell B
// Datum: Friday Dec 18th 2020
// bertrussell23@yahoo.in
// Version: 0.1.0
// TODO:
// 1. Receive inputs as arguments
// [DONE: Dec 18th 2020, 18::56]
// 2. Choose different dictionary sites: Wikictionary, Mari... | true |
f489abbf245f3a5343a78ab92dea02f5cddfc349 | Rust | alexcrichton/wiggle | /tests/strings.rs | UTF-8 | 3,377 | 2.84375 | 3 | [
"Apache-2.0",
"LLVM-exception"
] | permissive | use proptest::prelude::*;
use wiggle_runtime::{GuestError, GuestPtrMut, GuestString};
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
wiggle::from_witx!({
witx: ["tests/strings.witx"],
ctx: WasiCtx,
});
impl_errno!(types::Errno);
impl strings::Strings for WasiCtx {
fn hello_string(&self, a_s... | true |
e1ed3c483b81179379a874aa1b6c227d9ab7b625 | Rust | bartsmykla/codewars | /src/katas/k8_grasshopper_terminal_game_combat_function.rs | UTF-8 | 623 | 3.71875 | 4 | [
"MIT"
] | permissive | #![allow(unused)]
/*
Kata (8kyu): Grasshopper - Terminal game combat function
Url: https://www.codewars.com/kata/grasshopper-terminal-game-combat-function-1/train/rust
Create a combat function that takes the player's current health
and the amount of damage recieved, and returns the player's new health... | true |
2597e38793d3e3f865348c6bd28c3d65eaea8545 | Rust | mguomanila/miro | /src/config.rs | UTF-8 | 6,868 | 3.265625 | 3 | [
"MIT"
] | permissive | //! Configuration for the gui portion of the terminal
use regex::Regex;
use serde_json::Value;
use std;
use std::collections::HashMap;
use crate::term;
use crate::term::color::RgbColor;
#[derive(Debug, Deserialize, Clone)]
pub struct Config {
/// The font size, measured in points
#[serde(default = "default_fo... | true |
d871307b7540c89b26cc2b6dc697807f24bfe540 | Rust | MonkeyToiletLadder/oscar | /src/grover/error.rs | UTF-8 | 368 | 2.71875 | 3 | [] | no_license | pub enum ErrorCode {
MalformedExpression,
LexerError,
ParserError,
EvaluatorError,
ArithmeticError,
ReassignConstant,
}
pub struct Error {
pub code: ErrorCode,
pub message: String,
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result... | true |
7c3687a46b147a50fb485c002c4fad2eb972e775 | Rust | suclogger/leetcode-rust | /week/week249/unique-length-3-palindromic-subsequences/src/main.rs | UTF-8 | 1,219 | 3.046875 | 3 | [] | no_license | fn main() {
assert_eq!(count_palindromic_subsequence(String::from("aabca")), 3);
assert_eq!(count_palindromic_subsequence(String::from("bbcbaba")), 4);
assert_eq!(count_palindromic_subsequence(String::from("uuuuu")), 1);
assert_eq!(count_palindromic_subsequence(String::from("tlpjzdmtwderpkpmgoyrcxttihea... | true |
a11392e7d461ce51534dcd3d472716625d3f6fb1 | Rust | dusty-phillips/async-graphql | /src/types/empty_mutation.rs | UTF-8 | 1,481 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{registry, Context, ContextSelectionSet, GQLObject, GQLType, QueryError, Result};
use graphql_parser::query::Field;
use serde_json::{Map, Value};
use std::borrow::Cow;
/// Empty mutation
///
/// Only the parameters used to construct the Schema, representing an unconfigured mutation.
///
/// # Examples
///
/... | true |
4affadeeeda21f9c4d015ec7c816837efcf00524 | Rust | TAKEDA-Takashi/rust-project-euler | /project-euler/src/bin/problem-052.rs | UTF-8 | 772 | 3.1875 | 3 | [] | no_license | //! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2052
//!
//! 125874を2倍すると251748となる. これは元の数125874と順番は違うが同じ数を含む.
//!
//! 2x, 3x, 4x, 5x, 6x が x と同じ数を含むような最小の正整数 x を求めよ.
use itertools::Itertools;
fn main() {
println!(
"{}",
(1..)
.map(|n| {
(
... | true |
f2d5908c6d936541d4d85120dd4a85d3f17542c4 | Rust | hooops/crypto-crawler-rs | /crypto-rest-client/src/exchanges/gate/gate_swap.rs | UTF-8 | 2,198 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use super::super::utils::http_get;
use crate::error::Result;
use std::collections::BTreeMap;
const BASE_URL: &str = "https://api.gateio.ws/api/v4";
/// The RESTful client for Gate Swap markets.
///
/// * RESTful API doc: <https://www.gate.io/docs/apiv4/en/index.html#futures>
/// * Trading at: <https://www.gateio.pro/... | true |
4ce6080624f975959f9d4b1399a8615aeedfc6fc | Rust | xuecli/perf-zoo | /src/mutex-contention.rs | UTF-8 | 3,823 | 3.515625 | 4 | [] | no_license | use std::process;
use std::sync::mpsc::channel;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Instant;
use structopt::StructOpt;
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
#[derive(Debug, StructOpt)]
#[structopt(
name = "Perf Zoo: Mutext Contention",
about = "Explore the scalability of mutex i... | true |
b09260490f9138376cb340eba9d99fe635ab9198 | Rust | seanmonstar/tick | /examples/http.rs | UTF-8 | 2,434 | 2.828125 | 3 | [
"MIT"
] | permissive | extern crate env_logger;
extern crate mio;
extern crate tick;
use std::io::{self, Read, Write};
use tick::Interest;
struct Hello {
msg: &'static [u8],
pos: usize,
eof: bool,
}
impl Hello {
fn new() -> Hello {
Hello {
msg: b"HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nHello",
... | true |
233a2b0cd01a654fda444ac996d1f400af9d340f | Rust | atlanticrev/rust_learning | /src/strings.rs | UTF-8 | 1,582 | 4.375 | 4 | [] | no_license | pub fn test() {
// Strings are UTF-8 encoded!
let mut s1 = "Some string literal".to_string(); // Due to string literals impls Display tarit, it can be converted to String
s1.push_str("asd"); // Concatenate with string slice
s1.push('!'); // Concatenate with one character
println!("s1 string is: {}",... | true |
98690dba372aa27a00c5627f3d76659ae2b11039 | Rust | marti1125/culqi-rust | /src/culqi/subscription.rs | UTF-8 | 3,191 | 3.0625 | 3 | [
"MIT"
] | permissive | extern crate serde_json;
use client::Client;
use std::collections::HashMap;
#[derive(Debug)]
pub struct Subscription {
}
impl Subscription {
//! # Examples
//!
//! ```
//! let client = culqi::Client::new("{KEY}");
//! ```
//!
//! ```
//! let new_subscription = culqi::Subscription::ne... | true |
12e12e9b10f695ce91ea141b06655b9fe84fa5fe | Rust | astro/spacemsg | /schalterd/src/door.rs | UTF-8 | 3,818 | 2.8125 | 3 | [] | no_license | use iron::prelude::*;
use iron::status;
use iron::headers::{Authorization, Basic};
use iron::middleware::Handler;
use ijr::{JsonResponse, JsonResponseMiddleware};
use std::collections::BTreeMap;
use sysfs_gpio::{Pin, Direction, Error};
use std::thread::sleep;
use std::time::Duration;
use std::sync::{Arc, RwLock};
#[d... | true |
34cad6fd73af95d0dda716f5ce72850c1f6c3e4a | Rust | bytesnake/alco | /alco/src/lib.rs | UTF-8 | 4,782 | 2.75 | 3 | [] | no_license | use std::{
collections::HashMap,
env::args,
fs::File,
io::{BufRead, BufReader},
path::{Path, PathBuf},
process::{Command, Stdio},
};
pub fn black_box<T>(dummy: T) -> T {
unsafe {
let ret = std::ptr::read_volatile(&dummy);
std::mem::forget(dummy);
ret
}
}
fn... | true |
53fbc1fce2176e00894a0a7310509e141f3c6ded | Rust | usarekoski/icy | /icy-server/src/models.rs | UTF-8 | 1,186 | 2.75 | 3 | [] | no_license | use chrono::NaiveDateTime;
use chrono::prelude::*;
use diesel::prelude::*;
use diesel::PgConnection;
use serde::Serialize;
use crate::schema::*;
#[derive(Identifiable, Queryable, PartialEq, Debug)]
#[table_name="sensors"]
pub struct Sensor {
pub id: i32,
pub description: String,
}
#[derive(Identifiable, Quer... | true |
f9f3f6e5afe8fae4aaf02aabbab617d19c057bea | Rust | felixwatts/t2_bus | /examples/req_rsp.rs | UTF-8 | 1,726 | 2.96875 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use t2_bus::{serve_bus_in_process, Client, RequestProtocol, BusResult};
// Define protocol message types for request and response
#[derive(Clone, Deserialize, Serialize, Debug)]
struct HelloRequest(String);
#[derive(Clone, Deserialize, Serialize, Debug)]
struct HelloResponse(Strin... | true |
a1fea15701182289661096c90728f87de294c1a7 | Rust | liebharc/basic_dsp | /vector/src/vector_types/complex/complex_to_real.rs | UTF-8 | 26,167 | 2.90625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::super::{
Buffer, ComplexNumberSpace, Domain, DspVec, ErrorReason, FloatIndex, FloatIndexMut,
GetMetaData, MetaData, NumberSpace, PosEq, RealNumberSpace, RededicateForceOps, Resize,
ToRealResult, ToSlice, ToSliceMut, Vector, VoidResult,
};
use crate::array_to_complex;
use crate::multicore_support:... | true |
b4d272e82c72c1d26c2bcd34af9eac6e13a11517 | Rust | PsichiX/CallOfFerris-RAUI | /src/components/enemy.rs | UTF-8 | 1,587 | 3.015625 | 3 | [] | no_license | use ggez::{Context, GameResult};
use ggez_goodies::{
camera::{Camera, CameraDraw},
nalgebra_glm::Vec2,
};
use crate::{
utils::{AssetManager, Position},
HEIGHT,
};
const HEIGHT2: f32 = HEIGHT / 2.;
use super::player::Player;
pub struct Enemy {
position: Position,
}
impl Enemy {
pub fn new(po... | true |
a1eb8be726489428e2d551df2f6e1070660d873e | Rust | flegac/rust-mcts | /rust-tools/src/screen/dimension.rs | UTF-8 | 2,154 | 3.359375 | 3 | [] | no_license | #[derive(Copy, Clone, Eq, PartialEq, PartialOrd)]
pub struct Dim {
width: usize,
height: usize,
}
impl Dim {
pub fn new(width: usize, height: usize) -> Dim {
Dim { width, height }
}
}
impl Dimension for Dim {
fn width(&self) -> usize {
self.width
}
fn height(&self) -> usiz... | true |
f6f42e3f0436fe80e9c93b391419206704539c9c | Rust | plutolove/rust-datastructure | /src/collections/vector.rs | UTF-8 | 4,288 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use std::slice;
use std::ptr::{Unique, NonNull, self};
use std::mem;
use std::ops::{Deref, DerefMut};
use std::heap::{Alloc, Layout, Heap, oom};
use std::ops::{Index, IndexMut};
struct VecPtr<T> {
ptr: Unique<T>,
cap: usize,
}
impl<T> VecPtr<T> {
fn new() -> Self {
let cap = if mem::size_of::<T>() ... | true |
ac3b15f834903a9871d606f2e44f41bf40d3112d | Rust | AcrylicShrimp/mazemaze | /src/render/map_renderer.rs | UTF-8 | 1,437 | 2.65625 | 3 | [] | no_license | extern crate sdl2;
use super::font_renderer;
use sdl2::pixels;
use sdl2::rect;
use sdl2::render;
use sdl2::video;
pub struct MapRenderer {
blocks: std::collections::HashMap<u8, (sdl2::render::Texture, u32, u32)>,
line_height: i32,
}
impl MapRenderer {
pub fn new(renderer: &font_renderer::FontRenderer) -> Result<M... | true |
5c7bf0380c64c51582ea1b0d54972a2fa6788e73 | Rust | honzasp/comprsr | /src/zlib/decoder.rs | UTF-8 | 9,334 | 2.765625 | 3 | [] | no_license | use bits;
use inflate::inflater;
use checksums::adler32;
use zlib::error;
struct Decoder {
priv stage: Stage,
priv byte_buf: bits::ByteBuf,
}
enum Stage {
HeaderStage,
DataStage(inflater::Inflater, adler32::Adler32),
Adler32Stage(u32),
ErrorStage(~error::Error),
EndStage,
}
impl Decoder {
pub fn new(... | true |
ffbaf35a6c6a1c49457790eb53b9ec22d3cd3db1 | Rust | ajunlonglive/pakken | /util/src/project.rs | UTF-8 | 1,928 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::error::{PakError, PakResult};
use crate::PAKKEN_FILE_ENDING;
use ron::de::from_str;
use ron::ser::{to_string_pretty, PrettyConfig};
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
#[derive(Serialize, Deserialize, Debug)]
pub struct Project {
pub name: String... | true |
2d4271c1252314e9f92141923d9bad635d0c6a4a | Rust | Giovan/lumen | /lumen_runtime/src/otp/erlang/tests/unregister_1/with_atom_name/with_registered_name.rs | UTF-8 | 1,844 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
#[test]
fn with_same_process_returns_true() {
with_process_arc(|process_arc| {
let name = registered_name();
let name_atom: Atom = name.try_into().unwrap();
let pid_or_port = unsafe { process_arc.pid().as_term() };
assert_eq!(
erlang::register_2(name, pid_... | true |
d96bc63222bbb58600e4b8a3a239bcd75f1d0662 | Rust | peckpeck/rudder-language | /src/technique.rs | UTF-8 | 11,678 | 2.578125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::error::*;
use std::fs;
use std::path::Path;
use regex::Regex;
use lazy_static::lazy_static;
use toml;
use nom::combinator::*;
use nom::sequence::*;
use nom::bytes::complete::*;
use nom::character::complete::*;
use nom::branch::alt;
use nom::multi::m... | true |
ca982cecc79222917cfb71597ec80dba8de8caae | Rust | nomius10/self-practice | /aoc2020/day2/main.rs | UTF-8 | 1,472 | 3.25 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader, Error};
fn parse_line<'a>(val : &'a str) -> (usize, usize, char, &'a str) {
let mut split = val.split(": ");
let p1 = split.next().unwrap();
let pass = split.next().unwrap();
assert!(split.next() == None);
split = p1.split(" ");
let iv = ... | true |
54ee3083ea743eb3daa2de08601ffa1d09f8e26a | Rust | bvssvni/dsp-chain | /src/node.rs | UTF-8 | 3,283 | 3.03125 | 3 | [
"MIT"
] | permissive |
use buffer::DspBuffer;
use sound_stream::{
AudioBuffer,
Sample,
Settings,
};
use std::num::Float;
/// The type used for volume.
pub type Volume = f32;
/// The type used for panning.
pub type Panning = f32;
/// DSP Node trait. Implement this for any audio instrument or effects types that are to be used
//... | true |
ae9dcd5c7cae75bb234ad4c9f0ed1c8b9d155c6e | Rust | shssoichiro/oxipng | /src/deflate/deflater.rs | UTF-8 | 1,362 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::atomicmin::AtomicMin;
use crate::{PngError, PngResult};
use libdeflater::*;
pub fn deflate(data: &[u8], level: u8, max_size: &AtomicMin) -> PngResult<Vec<u8>> {
let mut compressor = Compressor::new(CompressionLvl::new(level.into()).unwrap());
// If adhering to a max_size we need to include at least ... | true |
759135929b49546972f378a4416fcd88c34b5639 | Rust | hyperium/h2 | /tests/h2-support/src/raw.rs | UTF-8 | 947 | 2.765625 | 3 | [
"MIT"
] | permissive | // ===== Build a codec from raw bytes =====
#[macro_export]
macro_rules! raw_codec {
(
$(
$fn:ident => [$($chunk:expr,)+];
)*
) => {{
let mut b = $crate::prelude::mock_io::Builder::new();
$({
let mut chunk = vec![];
$(
$crate... | true |
5ddac8976a355e48dcf914c1a06f024e312f6442 | Rust | EFanZh/LeetCode | /src/problem_0143_reorder_list/mod.rs | UTF-8 | 734 | 3.046875 | 3 | [] | no_license | use crate::data_structures::ListNode;
pub mod iterative;
pub trait Solution {
fn reorder_list(head: &mut Option<Box<ListNode>>);
}
#[cfg(test)]
mod tests {
use super::Solution;
use crate::test_utilities;
pub fn run<S: Solution>() {
let test_cases = [
(&[1, 2, 3, 4] as &[_], &[1, ... | true |
2f575cdaacf1912df7e67883e1aa483e611dde9c | Rust | icylisper/orb | /src/main.rs | UTF-8 | 2,753 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use std::io::{self, BufRead};
use serde_json::Value;
use zen_engine::DecisionEngine;
use zen_engine::model::DecisionContent;
use clap::{Args, Parser, Subcommand};
mod graph;
mod reader;
mod evaluator;
#[derive(Debug, Parser)]
struct Orb {
#[clap(subcommand)]
cmd: Cmd,
}
#[derive(Debug... | true |
ca8cb7ea6f33c6db0aff79cdd20a637973156ee2 | Rust | corylanza/rusty-gbc | /rusty_gbc/src/gbc/memory/mbc/mbc1.rs | UTF-8 | 3,628 | 3.234375 | 3 | [
"MIT"
] | permissive | use super::MemoryBank;
pub struct MBC1 {
rom_banks: Vec<Vec<u8>>,
ram_banks: Vec<Vec<u8>>,
selected_rom: u8,
two_bits: u8,
ram_enabled: bool,
/// ROM banking mode if false, RAM banking mode if true
ram_banking_mode: bool,
}
impl MBC1 {
pub fn load_rom(bytes: &Vec<u8>, rom_bank_count: u... | true |
ecc83f075e01cacb46a35f6f77315a034f490dbf | Rust | overdrivenpotato/rust | /src/tools/error_index_generator/build.rs | UTF-8 | 1,279 | 2.703125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use std::path::PathBuf;
use std::{env, fs};
use walkdir::WalkDir;
fn main() {
// The src directory (we are in src/tools/error_index_generator)
// Note that we could skip one of the .. but this ensures we at least loosely find the right
// directory.
let out_dir = PathBuf::from(env::var("OUT_DIR").unwra... | true |
8692c221ced953ac9eaab5eea3863f94525c5a10 | Rust | waynexia/anchored | /macro-test/src/lib.rs | UTF-8 | 1,206 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code)]
use std::sync::Arc;
use ::anchored::unanchored;
#[unanchored]
async fn simple() {}
#[unanchored]
async fn with_return_value() -> usize {
42
}
#[unanchored]
async fn with_param(input: usize) -> usize {
input
}
#[unanchored]
#[allow(clippy::needless_lifetimes)]
async fn with_lifetime<'a,... | true |
75d30fe51da0384da763ec3bdb86b27814398edc | Rust | MEM-Group/Rust-Semantics | /rustsem-ocaml/rust_tests/bindings/t8.rs | UTF-8 | 141 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive |
fn main() {
let mut x = 32;
{
let mut z = & mut x;
let mut t = & mut z;
* * t = 23;
}
println!("{}", x);
} | true |
bf7063c035d7c02526cdc6ffb3202a95b3e5d571 | Rust | pedromfedricci/playground | /src/bin/drop_check.rs | UTF-8 | 1,777 | 3.6875 | 4 | [] | no_license | use std::ops::{Deref, DerefMut};
#[derive(Debug)]
pub struct MyBox<T> {
ptr: *mut T,
}
impl<T> MyBox<T> {
pub fn new(value: T) -> Self {
// The Box is consumed, the heap allocation lives
// and it's pointed by the returing pointer of into_raw().
// Therefore, the user gets the responsa... | true |
9d6ef73ac2f49a5e3ce9ac4871bc916dc8174f79 | Rust | samuelogu/rust-example-projects | /database/src/main.rs | UTF-8 | 325 | 3.03125 | 3 | [] | no_license | fn main() {
let mut arguments = std::env::args().skip(1);
let key = arguments.next().expect("Key is required");
let value = arguments.next().unwrap();
println!("The key is {} and the value is {}", key, value);
let contents = format!("{}\t{}\n", key, value);
std::fs::write("database.rs", contents... | true |
da99a75851761becb94ba359ac3ab6e664ed1934 | Rust | arkworks-rs/algebra | /ec/src/hashing/tests.rs | UTF-8 | 1,886 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::hashing::curve_maps::swu::parity;
use ark_test_curves::bls12_381::{Fq, Fq2, Fq6};
#[test]
fn test_parity_of_prime_field_elements() {
let a1 = Fq::from(0);
let a2 = Fq::from(1);
let a3 = Fq::from(10);
assert_eq!(parity(&a1), false);
assert_eq!(parity(&a2), true);
assert_eq!(parity(&a3... | true |
d34c8a037f0765ef0a5a46a91aad8707cfcb2033 | Rust | djcsdy/wildflower-codec | /src/decode/tags/common/twips.rs | UTF-8 | 513 | 3.078125 | 3 | [] | no_license | use std::fmt;
use std::fmt::{Debug, Display, Formatter};
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct Twips<N>(pub N);
impl<N> Twips<N> {
pub fn new(twips: N) -> Twips<N> {
Twips(twips)
}
}
impl<N: Display> Display for Twips<N> {
fn fmt(&self, f: &mut Formatter<'_>) -> ... | true |
a0d1f516642eec199578297af22e8b28e1c751b9 | Rust | voidpumpkin/rusty-rougelike | /src/spawn.rs | UTF-8 | 5,152 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::{
components::{
BlocksTile, CombatStats, Item, Monster, Name, Player, Position, Potion, Renderable,
Viewshed,
},
map::{Map, MAPWIDTH},
rect::Rect,
State,
};
use rltk::{RandomNumberGenerator, RGB};
use specs::{
prelude::{Builder, WorldExt},
Entity, World,
};
const ... | true |
63a797c8ce86203c73647bdd5ee24fc66a1b5f19 | Rust | gengjiawen/leetcode | /DP/_2321_maximum_score_of_spliced_array.rs | UTF-8 | 2,731 | 3.59375 | 4 | [] | no_license | // https://leetcode.com/problems/maximum-score-of-spliced-array
//
// You are given two **0-indexed** integer arrays `nums1` and `nums2`, both of length `n`.
//
// You can choose two integers `left` and `right` where `0 <= left <= right < n` and **swap** the subarray `nums1[left...right]` with the subarray `nums2[left.... | true |
3e66cb96787a8d165b9a640e6c132712f14b9559 | Rust | tillrohrmann/rust-challenges | /aoc_2021_2/src/main.rs | UTF-8 | 611 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use std::fs;
fn main() {
let content = fs::read_to_string("input.txt").unwrap();
let lines: Vec<&str> = content.trim().split("\n").map(|line| line.trim()).collect();
solve_part_one(&lines);
solve_part_two(&lines);
}
fn solve_part_one(lines: &Vec<&str>) {
let position = aoc_2021_2::simulate_submar... | true |
3f8b37d7fc408e55913b3f81317b905d133fc2fc | Rust | xoyo24/nushell | /crates/nu-command/tests/commands/run_external.rs | UTF-8 | 7,066 | 2.609375 | 3 | [
"MIT"
] | permissive | use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn better_empty_redirection() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
ls | each { |it| nu --testbin cococo $it.name }
"#
... | true |
5cd11360dbf0e1a9bf689efe458aba122b446eaf | Rust | tonngw/leetcode | /rust/0735-asteroid-collision.rs | UTF-8 | 807 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
impl Solution {
pub fn asteroid_collision(asteroids: Vec<i32>) -> Vec<i32> {
let mut stack: Vec<i32> = vec![];
for mut asteroid in asteroids {
while !stack.is_empty() && asteroid < 0 && stack.last() > Some(&0) {
let diff = asteroid + stack.last()... | true |
2b28cdd1ad76eba0fd3d01bab08a79a1207fb8cc | Rust | Richard-W/mmu | /src/x86_64/page_table.rs | UTF-8 | 4,920 | 3.515625 | 4 | [
"MIT"
] | permissive | use super::*;
/// Defines a mapping from virtual to physical address space.
#[repr(align(4096))]
pub struct PageTable {
pub entries: [Entry; 512],
}
/// Page table entry.
#[derive(Debug, Clone, Copy)]
pub struct Entry {
entry: u64,
}
/// Properties of a page table entry.
#[repr(u64)]
#[derive(Debug, Clone, C... | true |
743c332dc21281dc4712764b77cfe7888d2845b5 | Rust | katyo/ledb | /ledb/src/filter.rs | UTF-8 | 10,349 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::iter::once;
use serde::{Serialize, Deserialize};
use lmdb::{ReadTransaction};
use super::{Identifier, Result, KeyData, Selection, Collection};
/// Comparison operator of filter
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Comp {
/// Equal
#[serde(rename = "$eq")]
Eq(Ke... | true |
3564af6b92cdd081461af2185111afe2fed22495 | Rust | rbelouin/midi-hub | /src/apps/youtube/client.rs | UTF-8 | 4,248 | 2.953125 | 3 | [] | no_license | pub use reqwest::{Client, Error};
use serde::{Serialize, Deserialize};
pub mod playlist {
use super::*;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Playlist {
pub items: Vec<PlaylistItem>,
pub next_page_token: Option<String>,
}
... | true |
83acb05f080cba2db8dc896c9e79bdbbab136a1a | Rust | swgillespie/pine | /pine_typecheck/src/typed_ast_visitor.rs | UTF-8 | 7,177 | 3.375 | 3 | [] | no_license | use typed_ast::*;
pub trait TypedVisitor: Sized {
type Return : Default;
fn visit_item(&mut self, item: &mut TypedItem) -> Self::Return {
walk_item(self, item);
Default::default()
}
fn visit_function(&mut self, func: &mut TypedFunction) -> Self::Return {
walk_function(self, fu... | true |
866853116e7cc331d00effdc0fef74d70af79dfa | Rust | suyanlongfamily/rust_study | /Study/eum_struct.rs | UTF-8 | 874 | 3.671875 | 4 | [] | no_license |
//单元结构体
struct Nil;
//元组结构体
struct Pair(i32, f32);
//普通结构体
struct Piont {
x: f32,
y: f32,
}
#[allow(dead_code)]
struct Rectangle {
p1: Piont,
p2: Piont,
}
fn main() {
//实例化普通结构体对象。
let piont: Piont = Piont { x: 0.3, y: 0.5 };
//结构体,成员默认不是私有的吗???
println!("piont info:({},{})", piont.... | true |
5494eab35e03947ea89fe11dd6c9b9480e6c1b02 | Rust | andrewrk/glium | /src/program.rs | UTF-8 | 47,538 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use gl;
use libc;
use std::{ffi, fmt, mem, ptr};
use std::collections::HashMap;
use std::sync::{Arc, Mutex, StaticMutex, MUTEX_INIT};
use std::sync::mpsc::channel;
use {Display, DisplayImpl, GlObject};
use context::{self, CommandContext, GlVersion};
use uniforms::UniformType;
use Handle;
/// Some shader compilers have... | true |
6807218dc409e8bea7a0e9a129f00c35f04051d1 | Rust | sunjay/async-std | /src/future/timeout.rs | UTF-8 | 1,951 | 3.3125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::error::Error;
use std::fmt;
use std::pin::Pin;
use std::time::Duration;
use futures_timer::Delay;
use crate::future::Future;
use crate::task::{Context, Poll};
/// Awaits a future or times out after a duration of time.
///
/// If you want to await an I/O future consider using
/// [`io::timeout`](../io/fn.tim... | true |
9f2d4c99bfb09fa965ca5e631fd35e1188a72ac2 | Rust | benluelo/smmo-api | /src/models/orphanage.rs | UTF-8 | 747 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt::{self, Display};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::models::{smmo_player::UserId, SmmoModel};
#[derive(Debug, Serialize, Deserialize)]
pub struct Orphanage {
pub current_amount: u64,
pub max_amount: u64,
pub recent_donators: Vec<RecentDonator>,
}
#... | true |
763da086b69051b505133fe11bfd273f6e504b80 | Rust | Trivernis/pixiv-rs | /src/error.rs | UTF-8 | 569 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt;
use std::error::Error as StdError;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Reqwest(reqwest::Error),
Pixiv(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error:... | true |
db3b045e41ab468afea3f4c8c7917147b6f21822 | Rust | leaysgur/dprint | /crates/dprint/src/cli/configuration/resolve_main_config_path.rs | UTF-8 | 4,157 | 2.671875 | 3 | [
"MIT"
] | permissive | use dprint_core::types::ErrBox;
use std::path::{Path, PathBuf};
use crate::cache::Cache;
use crate::cli::{CliArgs, SubCommand};
use crate::environment::Environment;
use crate::utils::{resolve_url_or_file_path, PathSource, ResolvedPath};
const DEFAULT_CONFIG_FILE_NAME: &'static str = "dprint.json";
const HIDDEN_CONFIG... | true |
ca7c8b441a0220f82a08abccd2aee7ad108f7ab9 | Rust | philipwastakenwastaken/network-rs | /common/src/transaction.rs | UTF-8 | 1,564 | 3.328125 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use crate::keys::sha::{double_sha256, Sha256Hash};
#[derive(Serialize, Deserialize)]
pub struct Transaction {
pub from: String,
pub to: String,
pub amount: f64
}
impl Transaction {
pub fn new(from: String, to: String, amount: f64) -> Self {
Transaction {
... | true |
93d96036419f99b538db090d59528ef4d1868d6f | Rust | ani003/prusti_panic_test | /panics/6/bin_given_limits/bin_given_limits.rs | UTF-8 | 2,667 | 3 | 3 | [
"MIT"
] | permissive | fn make_bins(limits: &Vec<usize>, data: &Vec<usize>) -> Vec<Vec<usize>> {
let mut bins: Vec<Vec<usize>> = Vec::with_capacity(limits.len() + 1);
for _ in 0..=limits.len() {bins.push(Vec::new());}
limits.iter().enumerate().for_each(|(idx, limit)| {
data.iter().for_each(|elem| {
if i... | true |
a8b89d513221db84581b77111c1e85ce1f2808eb | Rust | rgrig/plad | /code/CoinChange.rs | UTF-8 | 926 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::io;
use std::io::Read;
fn mmin(a : Option<i32>, b : Option<i32>) -> Option<i32> {
match (a, b) {
(None, c) | (c, None) => c,
(Some(x), Some(y)) => Some (if x < y {x} else {y})
}
}
fn main() {
let mut stdin = io::stdin();
let mut allinput = String::new();
stdin.read_to_stri... | true |
3e7d38eb379b5445edb3211d833992070b7c64fa | Rust | nanoqsh/platform | /src/tokens/refresh.rs | UTF-8 | 1,587 | 2.859375 | 3 | [] | no_license | use diesel::{
backend::Backend,
deserialize::{self, FromSql},
serialize::{self, Output, ToSql},
sql_types::Text,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, AsExpression, FromSqlRow, Serialize, Deserialize)]
#[sql_type = "Text"]
pub struct RefreshToken(String);
impl RefreshToken {
... | true |
3ea6c1f52dc5035a296d1a2489d572336bf9064c | Rust | pbl2019/aworld-datagen | /src/services/raycast.rs | UTF-8 | 3,810 | 2.8125 | 3 | [] | no_license | use crate::context::Context;
use crate::models::terrain::*;
use crate::models::{Object, ObjectId};
use crate::utils::intersects_circle_with_line;
impl Context {
pub fn raycast(&self, x0: f32, y0: f32, angle: f32, distance: f32) -> Option<Obstacle> {
let x1 = x0 + distance * angle.cos();
let y1 = y0... | true |
3cd36778cec70b67f2e12937b683c2edc14cd499 | Rust | projectfluent/fluent-rs | /fluent-bundle/src/types/mod.rs | UTF-8 | 11,667 | 3.421875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! `types` module contains types necessary for Fluent runtime
//! value handling.
//! The core struct is [`FluentValue`] which is a type that can be passed
//! to the [`FluentBundle::format_pattern`](crate::bundle::FluentBundle) as an argument, it can be passed
//! to any Fluent Function, and any function may return i... | true |
9e20dc8466dfdd0529b692c392e1b905af12bf87 | Rust | uchanchlani/os-rust | /src/vm_pool.rs | UTF-8 | 3,360 | 2.96875 | 3 | [] | no_license | use crate::{
process_table::MyProcess
};
use x86_64::VirtAddr;
use core::fmt::{Formatter, Error};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
struct VMPoolEntry {
start : VirtAddr,
size : u64 // number of pages it spans
}
impl VMPoolEntry {
fn end(& self) -> VirtAddr {
self.start +... | true |
a0338de89ca4dbb643b0cde8e0b6d8c2d3c494a7 | Rust | Feilkin/mela | /examples/hello2d/main.rs | UTF-8 | 1,374 | 2.953125 | 3 | [] | no_license | //! 3D graphics demo
use crate::states::States;
use mela::application::Application;
use mela::debug::DebugContext;
use mela::game::Playable;
use mela::gfx::RenderContext;
use mela::state::State;
use std::time::Duration;
use winit::event::{Event, WindowEvent};
use winit::event_loop::ControlFlow;
mod states;
struct He... | true |
315f964f1608bd1abb41280042bc8427c7586a87 | Rust | theduke/rust | /src/test/run-pass/issue-36744-bitcast-args-if-needed.rs | UTF-8 | 975 | 2.640625 | 3 | [
"MIT",
"NCSA",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | true |
288b30c1c2174223849ceed15bd25407490bc17d | Rust | fewensa/rtdlib | /src/types/chats.rs | UTF-8 | 1,737 | 2.8125 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Represents a list of chats
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Chats {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@ex... | true |
e855cc3bedf9db7ea1db139aa8ee343a895a11ee | Rust | carrotflakes/silver | /src/resolvers/transformed.rs | UTF-8 | 1,666 | 2.71875 | 3 | [] | no_license | use crate::bbox::BBox;
use crate::matrix::Matrix;
use crate::ray::Ray;
use crate::shapes::HitRec;
use super::Hit;
pub struct Transformed<M: Clone, T: Hit<M>> {
inner: T,
matrix: Matrix,
inv_matrix: Matrix,
_m: std::marker::PhantomData<M>,
}
impl<M: Clone, T: Hit<M>> Transformed<M, T> {
pub fn new... | true |
1790891775f318d16238e24dba357407ce9b2c20 | Rust | Forever-Young/ysv | /src/transform/replace.rs | UTF-8 | 1,367 | 3.140625 | 3 | [] | no_license | use crate::transform::CellValue;
use linked_hash_map::LinkedHashMap;
use regex::Regex;
fn replace_with_mapping(value: String, mapping: &LinkedHashMap<String, String>) -> String {
let mut result: String = value;
for (from, to) in mapping.iter() {
result = result.replace(from, to);
}
result
}
... | true |
7c3b1e19451a1bf3e046232fc6707849ddd50cc7 | Rust | limpidchart/lc-render | /examples/two_scatters_chart.rs | UTF-8 | 1,869 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use lc_render::{Chart, Color, LinearScale, PointType, ScatterView};
fn main() {
let width = 800;
let height = 600;
let margin_top = 90;
let margin_bottom = 50;
let margin_left = 60;
let margin_right = 40;
let x_scale = LinearScale::new(0.0, 200.0, 0, width - margin_left - margin_right);
... | true |
318c070ea1453d84175ca92a9eef2b0d546c1f2d | Rust | shirshak55/dog | /dns-transport/src/tcp.rs | UTF-8 | 3,683 | 2.953125 | 3 | [
"MIT"
] | permissive | use async_trait::async_trait;
use log::*;
use tokio::net::TcpStream;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use dns::{Request, Response};
use super::{Transport, Error};
/// The **TCP transport**, which uses the stdlib.
///
/// # Examples
///
/// ```no_run
/// use dns_transport::{Transport, TcpTransport};
/// ... | true |
e8870d7b26109e6235ebc181aaf3b9564e446b8f | Rust | sseritan/ss_leetcode | /0287_DupNum/src/main.rs | UTF-8 | 1,152 | 3.46875 | 3 | [] | no_license | struct Solution;
impl Solution {
// Extra stipulations: Use read-only array, O(1) space, and no worse than O(N^2) time
// Second attempt: Floyd's Tortoise and Hare
pub fn find_duplicate(nums: Vec<i32>) -> i32 {
let mut slow = nums[nums[0] as usize];
let mut fast = nums[nums[nums[0] as usize]... | true |
41aaec845e673a137d6c3fb0b93063104f7c7fd9 | Rust | c410-f3r/lightstore | /lightstore-crypto/src/secure.rs | UTF-8 | 4,665 | 2.71875 | 3 | [] | no_license | use super::*;
use generic_array::ArrayLength;
use std::ops::Deref;
pub struct Secure<N: ArrayLength<u8>> {
ptr: NonNull<u8>,
phantom: PhantomData<GenericArray<u8, N>>,
}
pub struct SecureGetRef<'a, N: ArrayLength<u8> + 'a> {
secure: &'a Secure<N>,
}
const COUNT_SIZE: usize = mem::size_of::<AtomicUsize>()... | true |
f8d31673d9589b7009ed16884750c019ee6b773c | Rust | richinfante/ibackuptool2 | /src/lib/crypto/keybag_block.rs | UTF-8 | 1,104 | 2.671875 | 3 | [] | no_license | use log::warn;
#[derive(Debug, PartialEq, Clone)]
pub enum KeybagBlockTag {
UUID,
CLAS,
WRAP,
WPKY,
KTYP,
PBKY,
VERS,
TYPE,
HMCK,
SALT,
ITER,
DPWT,
DPIC,
DPSL,
Unknown,
}
impl From<&str> for KeybagBlockTag {
fn from(string: &str) -> KeybagBlockTag {
... | true |
9d36b6c820470deebdeb2cbc6a6451f765789306 | Rust | vnetserg/ravel | /src/conn.rs | UTF-8 | 1,515 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::net::SocketAddr;
use std::io;
use mio::{Evented, Token, Poll, PollOpt, Ready};
use mio::net::TcpStream;
pub struct Connection {
id: usize,
listener: Option<usize>,
addr: SocketAddr,
stream: TcpStream,
}
impl Connection {
pub fn new(id: usize, listener: usize, stream: TcpStream,
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.