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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36a70279763a181bb6231f1037a2b4a61f51f657 | Rust | hasipon/icfpc2019-DiamondPrincess | /solutions/shohei_search11/vilog/src/trlog/config.rs | UTF-8 | 160 | 2.578125 | 3 | [] | no_license | pub struct TrlogConfig {
pub fps: f32
}
impl TrlogConfig {
pub fn new() -> TrlogConfig {
TrlogConfig {
fps: 15.0
}
}
}
| true |
639388b032786fbe4925230f8f26d958ae6967a7 | Rust | bartsmykla/codewars | /src/katas/k8_reversed_words.rs | UTF-8 | 618 | 3.78125 | 4 | [
"MIT"
] | permissive | #![allow(unused)]
/*
Kata (8kyu): Reversed Words
Url: https://www.codewars.com/kata/reversed-words/train/rust
Complete the solution so that it reverses all of the word
within the string passed in.
Example:
reverse_words("The greatest victory is that which requires no battle")
// should ... | true |
d7c7e7e804b7d81c0f0e2a2ff15586956305b1fd | Rust | Orca-bit/DataStructureAndAlgorithm | /src/string_problem/_remove_methods_to_palindrome.rs | UTF-8 | 1,092 | 2.96875 | 3 | [] | no_license | fn methods(s: String) -> i32 {
if s.is_empty() {
return 0;
}
let s = s.chars().collect::<Vec<_>>();
let n = s.len();
let mut dp = vec![vec![1; n]; n];
for i in 0..n - 1 {
if s[i] == s[i + 1] {
dp[i][i + 1] = 3;
} else {
dp[i][i + 1] = 2;
}
... | true |
893bf46d6b3ef06561fe854cb3450890b6e661a0 | Rust | HectorTa1989/8051ReverseEngineering | /src/instr.rs | UTF-8 | 9,348 | 2.59375 | 3 | [
"MIT"
] | permissive | /// An enum specifying the types of opcode an 8051 instruction can have.
pub enum InsType {
Resrv,
Acall,
Add,
Addc,
Ajmp,
Anl,
Cjne,
Clr,
Cpl,
Da,
Dec,
Div,
Djnz,
Inc,
Jb,
Jbc,
Jc,
Jmp,
Jnb,
Jnc,
Jnz,
Jz,
Lcall,
Ljmp,
M... | true |
9071e7e2ab70a713722cc96453812ba1adc834de | Rust | safrannn/leetcode_rust | /src/_1572_matrix_diagonal_sum.rs | UTF-8 | 748 | 3.359375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn diagonal_sum(mat: Vec<Vec<i32>>) -> i32 {
let n: usize = mat.len();
let mut result: i32 = 0;
for i in 0..n {
for j in 0..n {
if i == j || i == n - 1 - j {
result += mat[i][j];
}
... | true |
c70f2a81bf58a3c35bbd1cfb926f46acf9dfe73e | Rust | timdestan/cfg-learn | /src/lib.rs | UTF-8 | 9,445 | 3.203125 | 3 | [] | no_license | use itertools::Itertools;
use std::fmt;
use std::str::FromStr;
#[derive(PartialEq, Eq, Debug)]
enum Token<'a> {
OpenParen,
CloseParen,
Atom(&'a [u8]),
}
impl<'a> fmt::Display for Token<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Token::OpenParen => wri... | true |
028009825e77c3e96ecd50d1f35674887b115dbb | Rust | CarlEkerot/gameboy | /src/debugger/commands/breakpoint.rs | UTF-8 | 740 | 3.125 | 3 | [] | no_license | use std::fmt;
use debugger::Debugger;
use debugger::commands::Command;
pub struct Breakpoint(pub u16);
impl fmt::Display for Breakpoint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "${:04x}", self.0)
}
}
impl Command for Breakpoint {
type Item = Breakpoint;
fn parse(cmd:... | true |
7dbc1212aabcce99de12c305e43be2039d02ab8a | Rust | mstallmo/bi-focals | /src/rs/lib.rs | UTF-8 | 642 | 2.828125 | 3 | [
"MIT"
] | permissive | use wasm_bindgen::prelude::*;
use web_sys::Document;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
#[wasm_bindgen(start)]
pub fn main() {
let doc = Document::new().unwrap();
let img_elements = doc.get_elements_by_tag_name("img");
let element = img_element... | true |
5fc2788963e2d5027732fc9323ccd06c5b6f231a | Rust | claderoki/Intergalactica-Discord-Bot-Rust | /src/modules/shared/caching/human.rs | UTF-8 | 844 | 2.546875 | 3 | [] | no_license | use redis::Commands;
use crate::redis_utils::connection::get_connection_redis;
pub struct HumanCache;
impl HumanCache {
pub fn get_key(user_id: u64) -> String {
format!("human:{}", user_id)
}
pub fn get_id(user_id: u64) -> Option<i32> {
match get_connection_redis() {
Ok(mut co... | true |
8877097c1226cc329571a89c921a30fc23577e65 | Rust | hemanthgoalla/tock | /capsules/src/lora_console.rs | UTF-8 | 10,414 | 2.953125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::cell::Cell;
use core::cmp;
use core::str;
use kernel::capabilities::LoraManagementCapability;
use kernel::common::cells::TakeCell;
use kernel::debug;
use kernel::hil::uart;
use kernel::hil::usb;
use kernel::introspection::KernelInfo;
use kernel::Kernel;
use kernel::ReturnCode;
// Since writes are character... | true |
e4c13f2ac57f2234a5bda97aa4bfddde9e206a8b | Rust | seanpianka/leetcode-rust | /src/dp/trapping_rain_water.rs | UTF-8 | 1,813 | 3.375 | 3 | [] | no_license | /*! https://leetcode.com/problems/trapping-rain-water/
trapping_rain_water接雨水: 当前柱子能接水的最大高度等于两侧柱子高度的最小值-当前柱子的高度
所以第一个柱子和最后一个柱子的两侧只有一个柱子,必定不能接水
我们可以用动态规划的思想去优化寻找左侧最高柱子和右侧最高柱子的过程
*/
fn trap(nums: Vec<i32>) -> i32 {
let mut res = 0;
let n = nums.len();
if n == 0 || n == 1 {
return 0;
}
let mut... | true |
4b55c4a701e0fc02d4ec09edaac52493af388992 | Rust | bend-n/neat | /core/src/activation.rs | UTF-8 | 2,848 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::EnumConversion;
use nanoserde::{DeBin, SerBin};
#[derive(Debug, Clone, PartialEq, DeBin, SerBin)]
pub enum ActivationKind {
Input,
Tanh,
Relu,
Step,
Logistic,
Identity,
Softsign,
Sinusoid,
Gaussian,
BentIdentity,
Bipolar,
Inverse,
Selu,
}
impl EnumConversi... | true |
dc35fdc9fadd38b38e41b5d62132b853ad8762b1 | Rust | hopkinstechnocrats/FRCScouter | /src/server/network/decode.rs | UTF-8 | 18,660 | 2.53125 | 3 | [] | no_license | use super::Stream;
use super::packet::Packet;
/// Translates a string into a stream of packets to be used for local processing and handling
pub fn stream_from_raw(raw: &str) -> Stream {
let mut fin = Stream::new();
let mut data_chunks = raw.split(';');
for i in data_chunks.next() {
match i {
... | true |
af11a9111b786d7073b66db188f13622f805e363 | Rust | tawawhite/pigeon-rs | /src/cmd/connect.rs | UTF-8 | 1,442 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{arg, cmd, email_provider::setup_ses_client, helper::format_green};
use anyhow::{anyhow, Result};
use clap::{Arg, ArgMatches};
pub fn connect_args() -> [Arg<'static, 'static>; 2] {
[
Arg::with_name(cmd::CONNECT)
.takes_value(true)
.possible_values(&["aws"]),
Arg::... | true |
b36318c9065b41774e5a30f43e5b58e5c83669e8 | Rust | Xymist/zohohorrorshow | /examples/category_cycle.rs | UTF-8 | 1,136 | 2.734375 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | extern crate dotenv;
extern crate zohohorrorshow;
use dotenv::dotenv;
use zohohorrorshow::errors::*;
fn run() -> Result<i32> {
dotenv().ok();
// // Generate the client, with a valid auth token.
// let client = ZohoClient::new(&env::var("ZOHO_CLIENT_ID")?, &env::var("ZOHO_CLIENT_SECRET")?)
// .set... | true |
ade5b510ad50b117d004e0151786f0f4b3a84ed1 | Rust | bclube/ray_tracer | /src/surface/metal.rs | UTF-8 | 1,032 | 3 | 3 | [] | no_license | use color::sample::*;
use geometry::ray::*;
use geometry::vec3::*;
use surface::material::*;
pub struct Metal {
albedo: ColorSample,
fuzz: Dimension,
}
impl Metal {
pub fn new(albedo: ColorSample, fuzz: Dimension) -> Metal {
Metal {
albedo: albedo,
fuzz: fuzz.max(0.0).min(1... | true |
a626bf975599487f2a5f7db620d0ff03f59beeed | Rust | sm921/pattern-making | /clothes/src/pattern/common/dart.rs | UTF-8 | 839 | 3.203125 | 3 | [] | no_license | use pmdraw::shapes::{line::Line, point::Point};
use crate::pattern::measurements::Cm;
#[derive(Clone)]
pub struct Dart {
pub fst: Line,
pub snd: Line,
}
impl Dart {
pub fn middle(&self) -> Point {
self.fst.end
}
/// Create dart from 3 points
/// - fst - first line's edge point
//... | true |
942ba8be1a1aaed320b06ff6bd0ede6b3b5e4294 | Rust | Abubakarshaikh/Rust | /book/024-for_in_loop.rs | UTF-8 | 580 | 3.65625 | 4 | [] | no_license | use std::io;
fn main(){
println!("Enter any number 1 to 10");
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Invalid input");
let input_int:i32 = input.trim().parse().unwrap();
let mut a = 1;
let mut b = 1;
let mut res = 0;
println!("");
for i in 1..(input... | true |
f9b769c951fb7ad9bb67f15c702a959f32ffb19a | Rust | kokosabu/exercises | /The_Rust_Programming_Language/4_29_casting_between_types/src/main.rs | UTF-8 | 538 | 3.1875 | 3 | [] | no_license | use std::mem;
fn main() {
let one = true as u8;
let at_sign = 64 as char;
let two_hundred = -56i8 as u8;
println!("{}, {}, {}", one, at_sign, two_hundred);
let a = 300 as *const char; // `a` is a pointer to location 300.
let b = a as u32;
println!("{}", b);
unsafe {
let a = [0... | true |
f1b3dfcba716eb7c426f46b3c4c64e1362f2f972 | Rust | elisvathi/rustracer | /src/camera/camera.rs | UTF-8 | 3,159 | 3.421875 | 3 | [] | no_license | // Camera
use crate::{Float, Ray, Vec3};
#[derive(Copy, Clone)]
pub struct Camera {
pub position: Vec3,
pub direction: Vec3,
pub down: Vec3,
pub right: Vec3,
pub aperture: Float,
pub angle: Float,
pub focus_distance: Float,
}
impl Camera {
pub fn new(position: Vec3, lookat: Vec3, up: Ve... | true |
cf648be8dbb76927cf5308b02e7d034258192778 | Rust | Alin-kkk/icse2020 | /misc/derive.rs | UTF-8 | 169 | 2.9375 | 3 | [] | no_license |
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
struct Point {
x: u32,
y: u32,
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
enum Type {
Safe,
Unsafe,
}
| true |
c54715131c29091f83e179f4620d3a6392870796 | Rust | hmunozb/spin-langevin | /src/lib.rs | UTF-8 | 34,169 | 2.59375 | 3 | [] | no_license | use itertools::Itertools;
use nalgebra::{Vector3, Matrix3};
use ndarray::{Array2, ArrayView1, ArrayView2, ArrayView3, ArrayViewMut1, Axis, Zip, Array1};
use ndarray::parallel::prelude::*;
use num_traits::Zero;
use rand::Rng;
use rayon::prelude::*;
use simd_phys::r3::{Matrix3d4xf64, Vector3d4xf64};
use simd_phys::r3::c... | true |
09f903dcdae8d5d2effafe7d90a8099779fc3c0b | Rust | reinterpretcat/vrp | /rosomaxa/src/termination/target_proximity.rs | UTF-8 | 1,731 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
#[path = "../../tests/unit/termination/target_proximity_test.rs"]
mod target_proximity_test;
use super::*;
use crate::algorithms::math::relative_distance;
use std::marker::PhantomData;
/// Provides way to set stop algorithm when some close solution is found.
pub struct TargetProximity<C, O, S>
where
... | true |
5aec5f92ab7ddc3130cabfa888f1d505cd725418 | Rust | clfs/raytracer | /rtlib/src/scene.rs | UTF-8 | 2,272 | 2.984375 | 3 | [] | no_license | use std::rc::Rc;
use rand::{prelude::ThreadRng, Rng};
use crate::{
color::Color,
hit::HittableObjects,
material::{Dielectric, Lambertian, Metal},
point3::Point3,
sphere::Sphere,
};
pub fn random() -> HittableObjects {
fn rand_sphere(a: i32, b: i32, rng: &mut ThreadRng) -> Option<Sphere> {
... | true |
1b9e8fe074417df10fc7c2002b5dde4fa3e033e2 | Rust | colelawrence/knot | /auth/src/db/user_tokens.rs | UTF-8 | 7,758 | 2.703125 | 3 | [] | no_license | use actix::prelude::*;
use chrono::{DateTime, Utc};
use diesel::prelude::*;
use actix_web::Result;
use super::{db_error, models, schema, DbExecutor};
fn get_token_by_resource_id(
conn: &PgConnection,
by_resource_id: &str,
) -> Result<Option<models::UserToken>> {
use schema::user_tokens::dsl::*;
user... | true |
a99a7c5b5c4b7896603daac8355321a9304d7b97 | Rust | takuma-watanabe/tv | /src/utils.rs | UTF-8 | 925 | 3.0625 | 3 | [
"MIT"
] | permissive | pub trait Transpose<'a, Elem, Iter, T>
where
Elem: 'a,
Iter: IntoIterator<Item = &'a Elem>,
T: IntoIterator<Item = Iter>,
{
fn transpose(self) -> Transposed<'a, Elem, Iter>;
}
impl<'a, Elem, Iter, T> Transpose<'a, Elem, Iter, T> for T
where
Elem: 'a,
Iter: IntoIterator<Item = &'a Elem>,
T: ... | true |
791bdfa1035a960dbe22add0ee94895b4157f770 | Rust | tpywao/echo_server | /src/main.rs | UTF-8 | 1,285 | 3.21875 | 3 | [] | no_license | use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::net::SocketAddr;
use std::thread;
trait Handler: Send + Copy + 'static {
fn handle(&self, &mut TcpStream);
}
impl<F> Handler for F
where
F: Send + Copy + 'static + Fn(&mut TcpStream)
{
fn handle(&self, stream: &mut TcpStream) {
... | true |
7ead126371d4660a5be492a77568095589565682 | Rust | Keats/fid | /src/bit_array.rs | UTF-8 | 6,456 | 3.515625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use std::mem;
use serde::{Deserialize, Serialize};
type Block = u64;
const BLOCK_SIZE: usize = mem::size_of::<Block>() * 8;
#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub struct BitArray {
blocks: Vec<Block>,
}
impl BitArray {
/// Returns a zero-cleared bit array of size `size`.
p... | true |
954c879f9b1a996c2597476a1699bea42fc98dc2 | Rust | CyanFroste/pokemon_simulator_rust | /src/api/_nature.rs | UTF-8 | 3,834 | 2.734375 | 3 | [] | no_license | use super::HashMap;
#[derive(Debug, Clone)]
pub struct Nature {
pub name: String,
inc_stat: String,
dec_stat: String,
}
impl Nature {
fn new(name: &str, inc_stat: &str, dec_stat: &str) -> Self {
Self {
name: name.to_string(),
inc_stat: inc_stat.to_string(),
dec_stat: dec_stat.to_string(),
}
}
pub f... | true |
0e9922008be5da270a87de2a894aebeedbb699a9 | Rust | wine-app/wine-server | /src/bin/test.rs | UTF-8 | 748 | 2.671875 | 3 | [] | no_license | use serde_derive::Serialize;
use serde_urlencoded;
use reqwest;
use std::env;
use dotenv::dotenv;
#[derive(Serialize)]
struct FacebookLogin {
client_id: String,
redirect_uri: String,
state: String,
response_type: String
}
#[tokio::main]
async fn main() {
dotenv().ok();
let my_login = FacebookLogin {
... | true |
378e53a6bbd197dd37516b33e2110db6b77985c9 | Rust | DwaynesWorld/meshFS | /src/command/volume.rs | UTF-8 | 886 | 2.640625 | 3 | [] | no_license | use std::env;
use crate::server::volume_server::VolumeServer;
use crate::server::volume_server_options::VolumeServerOptions;
pub async fn start_volume_server(config_path: &str) {
let options = VolumeServerOptions::new(config_path).unwrap_or_else(|err| {
eprintln!("Error parsing configuration file: {}", er... | true |
2802620880492a4c4c5062b7d4eacbc9a2788fc3 | Rust | scturtle/fun.rs | /exercism/hamming.rs | UTF-8 | 289 | 3 | 3 | [] | no_license |
pub fn hamming_distance(a : &str, b : &str) -> Result<u32, &'static str> {
if a.len() != b.len() {
Err("inputs of different length")
} else {
Ok(a.chars().zip(b.chars())
.map(|(c1,c2)| if c1 == c2 {0} else {1})
.fold(0, |a,b| a+b))
}
}
| true |
e4810de53c1c026de8dcf2ffb6bac6f9d1dd0fcd | Rust | davedufresne/modern_snmp | /src/msnmp/src/request.rs | UTF-8 | 2,915 | 2.53125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{format_var_bind, msg_factory, Client, Session, Step};
use failure::Error;
use snmp_mp::{ObjectIdent, PduType, SnmpMsg, VarBind, VarValue};
use snmp_usm::{Digest, PrivKey};
use std::str::FromStr;
const MIB2_BASE_OID: [u64; 6] = [1, 3, 6, 1, 2, 1];
pub fn snmp_get<D, P, S>(
pdu_type: PduType,
oids: ... | true |
d256a8036639bf4047bc038996572ea40d4f5c6a | Rust | glella/primes | /Rust - Channels/primes2/src/common.rs | UTF-8 | 2,426 | 4.0625 | 4 | [] | no_license | use std::io::{self, Error, ErrorKind, Write};
use std::str::FromStr;
// print a prompt and get user input - gets a &str and returns a String
pub fn prompt(s: &str) -> String {
print!("{}", s);
io::stdout().flush().unwrap(); // flush it to the screen
let mut text = String::new();
io::stdin()
.r... | true |
bcdb0cd169f82183f015c617a4b8e4b445994edf | Rust | TedDriggs/darling | /core/src/usage/lifetimes.rs | UTF-8 | 11,706 | 2.984375 | 3 | [
"MIT"
] | permissive | use fnv::FnvHashSet;
use syn::punctuated::Punctuated;
use syn::{Lifetime, Type};
use crate::usage::Options;
/// A set of lifetimes.
pub type LifetimeSet = FnvHashSet<Lifetime>;
/// A set of references to lifetimes.
pub type LifetimeRefSet<'a> = FnvHashSet<&'a Lifetime>;
/// Searcher for finding lifetimes in a synta... | true |
2430ffcd3a608c5bcb94284d091739e9be1c8478 | Rust | Rust-Wroclaw/rust-wroclaw | /talk-archive/2020-02-fantastic-actors-and-where-to-find-them/rustycabs/src/system/locator/actor.rs | UTF-8 | 1,069 | 2.859375 | 3 | [] | no_license | use std::collections::HashMap;
use tokio::stream::StreamExt;
use tokio::sync::mpsc;
use crate::math::Point;
use crate::system::CabId;
use super::LocatorMsg;
#[derive(Default)]
pub struct LocatorActor {
positions: HashMap<CabId, Point>,
}
impl LocatorActor {
pub async fn start(mut self, mut mailbox: mpsc::U... | true |
bb829ddc93ce7d74dd187951403919f967074745 | Rust | asukharev/cooperative-multitasking | /src/main.rs | UTF-8 | 7,619 | 2.75 | 3 | [] | no_license | mod task {
use std::{
future::Future,
pin::Pin,
sync::atomic::{AtomicU64, Ordering},
task::{Context, Poll},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct TaskId(u64);
impl TaskId {
fn new() -> Self {
static NEXT_ID: ... | true |
6eec67413f43e620d014777de865f29e693cd6d6 | Rust | szqh97/test | /rust/read_write.rs | UTF-8 | 510 | 2.765625 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::fs::File;
#[macro_use]
pub fn read_test() {
let mut f = match File::open("./Cargo.toml") {
Ok(f) => f,
Err(_) => panic!("no such file"),
};
let mut file = try!(File::open("./Cargo.toml").map_err(|e| e.to_string()));
//let mut f1 = try!(Fil... | true |
702f2a4648f5d68191d12c4c5b903f6e8f32bc88 | Rust | seanlth/sulfide | /src/document.rs | UTF-8 | 1,365 | 2.9375 | 3 | [] | no_license | use element::Element;
use geometry::Rect;
use container::Container;
pub struct Document {
pub root: Option<Container>
}
impl Document {
pub fn new() -> Document {
Document {
root: None
}
}
pub fn set_root(&mut self, root: Container) {
self.root = Some(root);
... | true |
5d606349b88da071d5bdc70a3054dfa6d51b6cce | Rust | ragne/tail-stack-events-rust | /src/arg_parse.rs | UTF-8 | 3,962 | 2.96875 | 3 | [] | no_license | use clap::{App, Arg};
use rusoto_core::Region;
use std::cmp;
use std::str::FromStr;
pub(crate) struct Config {
pub region: Region,
pub stack_name: String,
pub debug: u8,
pub role_name: Option<String>,
pub profile_name: Option<String>,
pub follow: bool,
pub num_events: u8,
pub timeout: u... | true |
775145a28756392421b5cf2b5969ce8e7fa4f35c | Rust | xgillard/killall | /src/uid.rs | UTF-8 | 2,658 | 3.171875 | 3 | [] | no_license | // Copyright 2020 Xavier Gillard
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, di... | true |
9261ca47947371dae35b3f978f38215f56463472 | Rust | macisamuele/jsonschema-validator | /src/iterator_utils/generator_iterator.rs | UTF-8 | 1,614 | 3.453125 | 3 | [
"MIT"
] | permissive | use std::{
ops::{Generator, GeneratorState},
pin::Pin,
};
#[allow(dead_code)] // GeneratorIterator not yet used in the codebase (other than tests)
#[allow(missing_debug_implementations)] // No debug implementation to avoid to consume the generator
pub(in crate) struct GeneratorIterator<Y>(Box<dyn Generator<Yie... | true |
e626a44584b9e03b24ac5d33be15c5268b15cc40 | Rust | marc47marc47/leetcode-cn | /337house-robber-iii/houserobber/src/main.rs | UTF-8 | 1,156 | 3.625 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
}
pub struct Solution {}
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
... | true |
3f3e78ecec8cf819b44d662311d402bbdac35af3 | Rust | wasmerio/wasmer | /lib/c-api/src/wasm_c_api/externals/mod.rs | UTF-8 | 5,501 | 2.703125 | 3 | [
"MIT"
] | permissive | mod function;
mod global;
mod memory;
mod table;
use super::store::StoreRef;
// use super::types::{wasm_externkind_enum, wasm_externkind_t};
pub use function::*;
pub use global::*;
pub use memory::*;
pub use table::*;
use wasmer_api::{Extern, ExternType, Function, Global, Memory, Table};
#[allow(non_camel_case_types)... | true |
948e2279993048fee7ba7797e912e5d83370070c | Rust | rjmholt/mips-disasm-rust | /src/mips/decode.rs | UTF-8 | 5,872 | 2.78125 | 3 | [] | no_license | use std::result::Result;
use mips::data::*;
pub fn decode_instruction(x: u32) -> Result<Instr, String>
{
let opcode = get_opcode(x);
match opcode {
P_ZERO => decode_zero_prefix_instruction(x),
P_ADDI => {
let (rs, rt, imm) = get_itype_fields(x);
Ok(Instr::AddI(AddI { r... | true |
d836bc4bbdc1c07b88d72ee7c9851027792878ed | Rust | kprav33n/aoc18.rs | /src/day25.rs | UTF-8 | 2,168 | 3.171875 | 3 | [] | no_license | use petgraph::algo::connected_components;
use petgraph::graphmap::UnGraphMap;
use std::str::FromStr;
/// Find the number of constellations formed by the given points.
pub fn num_constellations(input: &str) -> usize {
let points: Vec<Point4D> = input
.trim()
.split('\n')
.map(|s| Point4D::fr... | true |
3fd0e114f43d859c2048becfc9cc7591438839e8 | Rust | dunkelstern/bookrss | /src/server/views/cover.rs | UTF-8 | 1,043 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::path::Path;
use std::str::FromStr;
use diesel::prelude::*;
use rocket::http::Status;
use rocket::request::Request;
use rocket::response::{self, Failure, Response, NamedFile, Responder};
use config::Config;
use database::DbConn;
use lib::models::*;
pub struct FileWithType(NamedFile);
impl<'r> Responder<'... | true |
14d1f4405bd89ae1cd0225f03ebdd26b1e831351 | Rust | stackcats/leetcode | /algorithms/medium/matchsticks_to_square.rs | UTF-8 | 686 | 2.6875 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn makesquare(matchsticks: Vec<i32>) -> bool {
let sum: i32 = matchsticks.iter().sum();
if sum % 4 != 0 {
return false;
}
let target = sum / 4;
let mut dp = vec![-1; 1 << matchsticks.len()];
dp[0] = 0;
for mask in 0..dp.len() {
... | true |
d12825771c1af0176bdba1eb56588287668167f4 | Rust | Nadrieril/pest_consume | /pest_consume/src/parser.rs | UTF-8 | 1,175 | 2.96875 | 3 | [
"MIT",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | use crate::{Error, Nodes};
use pest::Parser as PestParser;
use pest::RuleType;
/// A trait that provides methods to parse strings.
/// Do not implement manually; instead use the [`parser`] macro provided by this crate.
///
/// [`parser`]: macro@crate::parser
pub trait Parser {
type Rule: RuleType;
#[doc(hidden... | true |
2b7d152953980d1251e46ee5dbfdef5953953a3c | Rust | msarmi9/rustic | /src/sorts/quick.rs | UTF-8 | 2,051 | 4.09375 | 4 | [] | no_license | //! Quick Sort
/// In-place quick sort.
///
/// # Complexity
///
/// Best: O(n*log(n))
/// Average: O(n*log(n))
/// Worst: O(n^2)
///
pub fn quicksort<T: Ord>(arr: &mut [T]) {
if arr.len() <= 1 { return };
let idx = partition(arr);
quicksort(&mut arr[..idx]);
quicksort(&mut arr[idx..]);
}
/// In-plac... | true |
d762b7832c42b01a47392cd621a30685f270a88b | Rust | Swatinem/rust-analyzer | /crates/ide_assists/src/handlers/generate_default_from_new.rs | UTF-8 | 6,894 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
assist_context::{AssistContext, Assists},
AssistId,
};
use ide_db::helpers::FamousDefs;
use syntax::{
ast::{self, Impl, NameOwner},
AstNode,
};
// Assist: generate_default_from_new
//
// Generates default implementation from new method.
//
// ```
// struct Example { _inner: () }
//
// impl... | true |
f4c0f9d6c1332460e6486854371549c03f323e84 | Rust | mapx/leetcode-rust | /src/n1311_get_watched_videos_by_your_friends.rs | UTF-8 | 4,965 | 3.15625 | 3 | [
"MIT"
] | permissive | /**
* [1311] Get Watched Videos by Your Friends
*
* There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.
*
* Level 1 of... | true |
9498acb1e0c58bc0ca56c921c1f395dc7bf60c41 | Rust | CompSciGuyIT/Udemy_RustForCompleteBeginners_getskillsfast | /src/vectors_with_capacity.rs | UTF-8 | 363 | 3.015625 | 3 | [] | no_license | fn main() {
let mut vect: Vec<i32> = Vec::with_capacity(3);
println!("Capacity: {:?}", vect.capacity());
vect.push(5);
vect.push(8);
vect.push(3);
println!("Capacity: {:?}", vect.capacity());
println!("Values: {:?}", vect);
vect.push(4);
println!("Capacity: {:?}", vect.capacity(... | true |
12fbd37b5719ba80341e5dd89dd364d12c7cc39a | Rust | dadozsp/reforge | /src/star_map/station/station_server.rs | UTF-8 | 6,001 | 2.546875 | 3 | [] | no_license | use std::collections::HashMap;
use std::sync::Arc;
use std::sync::mpsc::{Sender, Receiver};
use chat::ChatMsg;
use login::AccountBox;
use module::{ModelStore, ModuleStored};
use net::{ClientId, ServerSlot, ServerSlotId, SlotInMsg, InPacket, OutPacket};
use star_map::StarMapAction;
use star_map::station::{Ship... | true |
0c55ba39158dee43a603abeba0c3627fc9d032df | Rust | werner/odoo-xmlrpc-rs | /src/main_request.rs | UTF-8 | 747 | 2.765625 | 3 | [] | no_license | use std::collections::BTreeMap;
use xmlrpc::{Request, Value, Error};
pub struct BasicRequest<'a> {
base_url: &'a str
}
impl<'a> BasicRequest<'a> {
pub fn new(url: &'a str) -> BasicRequest {
BasicRequest {
base_url: url
}
}
pub fn authenticate(&mut self, db: &str, username: &str, password: &str... | true |
75c06bcc08a537ebd3287f807fb1297a3a259a9c | Rust | luojia65/cc2640r2f | /src/flash/fcfg_bank.rs | UTF-8 | 6,196 | 2.625 | 3 | [
"WTFPL"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::FCFG_BANK {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... | true |
a64ffdf3f49582c5e254842de43fb479604e53af | Rust | bIgBV/ethereal-interpreter | /src/scanner.rs | UTF-8 | 13,564 | 3.046875 | 3 | [] | no_license | use std::{collections::HashMap, sync::RwLock};
use once_cell::{sync::Lazy, sync_lazy};
use crate::{
common::{EthNum, EthString, Token, TokenKind},
error::error,
};
static KEYWORDS: Lazy<RwLock<HashMap<&'static str, TokenKind>>> = sync_lazy! {
let mut m = HashMap::new();
m.insert("and", TokenKind::And... | true |
b488a330516ab8637f97368fdfb6463e84ceb23e | Rust | 5l1v3r1/myodine | /src/conn/highway.rs | UTF-8 | 656 | 2.984375 | 3 | [] | no_license | use std::io;
use dns_proto::Message;
/// An event from a `Highway`.
#[derive(Debug)]
pub enum Event {
Response(usize, Message),
Timeout(usize),
SendError(usize, String),
ConnectError(usize, io::Error),
SocketError(usize, io::Error)
}
/// A batched DNS requester.
pub trait Highway {
/// Get th... | true |
9836f04fad411f2df43e67a505e3cdd7121d91e6 | Rust | guigui64/stybulate | /src/unstyle.rs | UTF-8 | 2,440 | 3.734375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt;
/// Trait to implement when a string length differs from its unstyled value length (ASCII escapes
/// for instance)
pub trait Unstyle: fmt::Display {
/// Returns the same string without the style-related chars/codepoints
fn unstyle(&self) -> String {
self.to_string()
}
/// Return... | true |
15824864ca8dd6c141192959d3621204b4450e22 | Rust | enzopoeta/rust_playground | /actix_demo/src/main.rs | UTF-8 | 4,264 | 2.609375 | 3 | [] | no_license | use actix_web::middleware::Compress;
use actix_web::middleware::Logger;
use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder};
use env_logger::Env;
use jsonwebtoken::{dangerous_insecure_decode, Algorithm, Validation};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use serde::... | true |
775ac4f102a0136548bed09e64dd94c1f4cf2ab4 | Rust | CPPUer/mirror-clone | /src/stream_pipe.rs | UTF-8 | 6,869 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | //! ByteStreamPipe pipes TransferURL to ByteObject.
//!
//! A `ByteStreamPipe` is a wrapper on sources which yields `TransferURL`.
//! After piping a source through `ByteStreamPipe`, it will become a source
//! storage which yields `ByteStream`.
//!
//! Currently, this is done by downloading files to local file system,... | true |
1b5998b377ccb70805709bf8819ceeffb177e56e | Rust | yskszk63/hellomyothello | /src/square.rs | UTF-8 | 2,035 | 3.203125 | 3 | [] | no_license | use std::cell::Cell;
use graphics;
use graphics::Context;
use graphics::rectangle;
use opengl_graphics::GlGraphics;
use app::AppEnv;
use stone::Stone;
pub struct Square {
stone: Cell<Stone>,
x: u32,
y: u32,
focused: Cell<bool>,
}
impl Square {
pub fn new(x: u32, y: u32) -> Square {
Square ... | true |
0ae5bb3611dedba4f9042af84486baf63a3bfbdc | Rust | nickwb/nickwb-advent | /2020/rust/src/day20/monster.rs | UTF-8 | 4,636 | 2.796875 | 3 | [] | no_license | use super::{
bitmap::{all_bitmap_variants, Bitmap},
wave::CandidateGrid,
};
use bitvec::prelude::*;
pub fn subtract_monsters(image: &ResolvedImage) -> Option<ResolvedImage> {
// Flip and rotate the image until we find a variant with monsters in it
all_bitmap_variants()
.filter_map(|(flip, rotat... | true |
77317a418eb74b6bc0a645917fc0dab3c0def2ab | Rust | sappharx/fifteen-rs | /src/util.rs | UTF-8 | 327 | 3.015625 | 3 | [] | no_license | pub fn get_starting_index(size: u8, row: u8, col: u8) -> u8 {
size * size - row * size - (col + 1)
}
#[cfg(test)]
mod tests {
use crate::get_starting_index;
#[test]
fn test_get_starting_index() {
assert_eq!(get_starting_index(4, 0, 0), 15);
assert_eq!(get_starting_index(4, 3, 3), 0);
... | true |
133552e44a684e2484e1241d2e6bd53825e10d94 | Rust | mzabaluev/jormungandr | /testing/jormungandr-testing-utils/src/testing/measurement/attribute/consumption.rs | UTF-8 | 1,807 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::testing::measurement::{marker::ResourcesUsage, status::Status, thresholds::Thresholds};
use std::{cmp::Ordering, fmt};
#[derive(Clone, Debug)]
pub struct Consumption {
average_usage: ResourcesUsage,
}
impl fmt::Display for Consumption {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
9d827a681b27462afc1e23a4df83f907b9dc0f72 | Rust | songww/luwu | /src/responder.rs | UTF-8 | 3,199 | 2.53125 | 3 | [] | no_license | use std::io::Cursor;
#[cfg(feature = "msgpack")]
use rmps;
use rocket::http::{ContentType, MediaType, Status};
use rocket::request::Request;
use rocket::response::{self, Responder, Response};
use rocket::serde::Serialize;
#[cfg(feature = "json")]
use serde_json;
pub struct DynResponse<C>
where
C: Serialize,
{
... | true |
447efd952b4144b6067b2a71c4d352bd33060146 | Rust | Kalininator/AOC-2020 | /day_1/src/main.rs | UTF-8 | 1,071 | 3.1875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::io::{BufRead, BufReader};
fn read_file(path: &str) -> Vec<i32> {
println!("Reading file {}", path);
let file = fs::File::open(path).expect("Failed to read file");
let br = BufReader::new(file);
br.lines()
.map(|l| {
l.expect("Failed to get line.... | true |
c8c2514ad58cafaf7a159ee81720e5338dbb035e | Rust | edgex004/rust-hdl | /rust-hdl-core/src/code_writer.rs | UTF-8 | 1,551 | 3.78125 | 4 | [
"MIT"
] | permissive | pub struct CodeWriter {
lines: Vec<(usize, String)>,
// Each line consists of an indent level and a string of text
indent: usize,
// CodeWriter provides a buffer for assembling lines too
buffer: String,
}
impl CodeWriter {
pub fn new() -> CodeWriter {
CodeWriter {
lines: vec... | true |
746423f07c50d4e5d6d28d47e24554338b77b9c1 | Rust | CAD97/annotate-snippets-rs | /tests/fixtures_test.rs | UTF-8 | 1,769 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod diff;
mod snippet;
use crate::snippet::SnippetDef;
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::Snippet;
use glob::glob;
use serde::Deserialize;
use std::error::Error;
use std::fs::File;
use std::io;
use std::io::prelude::... | true |
2124d9bcf932e9037e03dfdfa308ed0807add9b4 | Rust | ZePedroResende/AP | /1/src/main.rs | UTF-8 | 5,533 | 3.046875 | 3 | [] | no_license | use nalgebra::{DMatrix/*, Dynamic, Matrix, VecStorage*/};
use gnuplot::{Caption, Color, Figure};
use rand::{distributions::Distribution, distributions::Uniform, seq::SliceRandom, Rng};
//type DMatrixi32 = Matrix<i32, Dynamic, Dynamic, VecStorage<i32, Dynamic, Dynamic>>;
fn get_town_rand(size: usize) -> Vec<usize> {
... | true |
4562241388238f4e96edafaac0371f733a4f6822 | Rust | loarabia/AdventOfCode | /2022/aoc03/src/main.rs | UTF-8 | 2,224 | 3.46875 | 3 | [] | no_license | use std::fs::{read_to_string};
use std::collections::HashMap;
use itertools::Itertools;
fn main() {
let input = read_to_string("input.txt").expect("Couldn't read input.text");
println!("{}", part1(&input));
println!("{}", part2(&input));
}
fn split_sack(input:&str) -> (&[u8], &[u8]) {
let data: &[u8]... | true |
76a9630aa37755f0f0d82cbf1466bbe5cf35a490 | Rust | ASIF1998/client-server-row-distortion | /server/src/main.rs | UTF-8 | 3,549 | 3.15625 | 3 | [] | no_license | use std::net::{TcpListener, Shutdown};
use std::thread;
use std::sync::mpsc;
use std::fmt::Write as FmtWrite;
// Стандартный ввод/вывод.
use std::io:: {
// Список, определяющий общие категории ошибок ввода-вывода.
ErrorKind,
// Характеристика чтения позволяет считывать байты из источника.
Read,
// ... | true |
f72285a63420b15a71e4fb47eb894bbc1fcb82ad | Rust | syohex/exercism | /rust/bob/src/lib.rs | UTF-8 | 567 | 3.265625 | 3 | [
"MIT"
] | permissive | pub fn reply(message: &str) -> &str {
let cs: Vec<char> = message
.trim()
.chars()
.filter(|c| c.is_alphabetic())
.collect();
let all_upper = cs.len() >= 1 && cs.iter().all(|c| c.is_uppercase());
if all_upper && message.trim_end().ends_with('?') {
"Calm down, I know w... | true |
9dbe042da8a970f397c3fa2acfb97efa91c7aa75 | Rust | lex148/leftwm | /src/bin/leftwm.rs | UTF-8 | 7,247 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Starts leftwm programs.
//!
//! If no arguments are passed, starts `leftwm-worker`. If arguments are passed, starts
//! `leftwm-{check, command, state, theme}` as specified, and passes along any extra arguments.
use clap::{crate_version, App, AppSettings, SubCommand};
use leftwm::child_process::{self, Nanny};
use ... | true |
2b2de1eebb6c2cfeaf6806c6a536244fa0568634 | Rust | leonardinius/rust-guide | /2.12-arr-vec-slice/src/main.rs | UTF-8 | 904 | 3.3125 | 3 | [
"MIT"
] | permissive | fn _12_1(){
println!("guide 12-1");
let a = [1i32, 2i32, 3i32];
let mut m = [2i32, 3i32, 4i32];
if false {
println!("{:?} {:?}", a, m);
}
let b = [0i32; 20]; // shorthand for array of 20 elements all initialized to 0
println!("{:?}", b);
m = [5i32, 6i32, 7i32];
println!("{:?}... | true |
309aba53e50c4f2aef2e8da7a0d925781e79d896 | Rust | Byron/depot | /src/rust/calendar/src/main.rs | UTF-8 | 20,028 | 3.46875 | 3 | [
"Artistic-2.0"
] | permissive | //! Derived from:
//! <https://raw.githubusercontent.com/quickfur/dcal/master/dcal.d>.
#![feature(conservative_impl_trait)]
extern crate chrono;
extern crate itertools;
use chrono::{Datelike, NaiveDate};
use itertools::Itertools;
///
/// Generates an iterator that yields exactly n spaces.
///
fn spaces(n: usize) -> ... | true |
8cb40971f7cbbe8c4f7079e7d083a59d08ced0f5 | Rust | indygreg/starlark-rust | /starlark/src/values/fast_string.rs | UTF-8 | 4,954 | 3 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/lic... | true |
88f5f5079ef326900bfc4f322386b7323014fbb5 | Rust | aiuto/starlark-rust | /starlark/src/values/interpolation.rs | UTF-8 | 10,109 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2018 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/lic... | true |
3e5d984df809f639ec5257f9e762c454182922e2 | Rust | jwilm/hydra | /src/util.rs | UTF-8 | 1,132 | 3.0625 | 3 | [] | no_license | //! Misc utilities for Hydra
use std::io::{self, ErrorKind};
use std::net::{ToSocketAddrs, SocketAddr};
/// Threading utilities
pub mod thread {
/// Like `thread::spawn`, but with a `name` argument
pub fn spawn_named<F, T, S>(name: S, f: F) -> ::std::thread::JoinHandle<T>
where F: FnOnce() -> T,
... | true |
c294ddf23a91e9eec362a47206ef6b8207eab642 | Rust | halazouna/stm32f429zi_tockos | /chips/nrf5x/src/timer.rs | UTF-8 | 8,643 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Timer driver, nRF5X-family
//!
//! The nRF51822 timer system operates off of the high frequency clock
//! (HFCLK) and provides three timers from the clock. Timer0 is tied
//! to the radio through some hard-coded peripheral linkages (e.g., there
//! are dedicated PPI connections between Timer0's compare events and
/... | true |
5ac09ca14ecb05f497d6dd0061cf7a181523f435 | Rust | Cassin01/PracticeForCompetitiveProgramming | /at_coder/C/abc_134/src/main.rs | UTF-8 | 970 | 3.125 | 3 | [] | no_license | use std::io::prelude::*;
fn input<T>() -> T
where T: std::str::FromStr {
let stdin = std::io::stdin();
let token: String = stdin
.lock()
.bytes()
.map(|c| c.unwrap() as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect();
... | true |
6451b36b3f854a378fc8e79edc405a28266b591e | Rust | zsytssk/test | /wasm/src/lib.rs | UTF-8 | 141 | 2.671875 | 3 | [
"MIT"
] | permissive | #[no_mangle]
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[no_mangle]
pub fn sum() -> String {
String::from("hello world")
}
| true |
0f70745f1bb7742fe733e7ede88a55bb53281023 | Rust | hansyuan/learn-rust | /src/gentle/ch2/structs.rs | UTF-8 | 989 | 4.0625 | 4 | [] | no_license |
#[derive(Debug)] // Allows debug outputs like a dictionary
struct Spacetime {
x: i64,
y: i64,
z: i64,
t: i64,
}
impl Spacetime {
// A constructor, probably.
// Is this a static method?
fn new(x:i64, y:i64, z:i64, t:i64) -> Spacetime {
Spacetime {
x: x,
... | true |
020d05620091affb735543b8118015c0f2b3d935 | Rust | BlueGhostAlt/advent-of-code-2020 | /src/day06.rs | UTF-8 | 832 | 3.046875 | 3 | [
"Unlicense"
] | permissive | use std::collections::HashSet;
pub fn part1(input: &str) -> usize {
input
.split("\n\n")
.map(|group| {
let mut answers = group.lines().flat_map(|l| l.chars()).collect::<Vec<_>>();
answers.sort_unstable();
answers.dedup();
answers.len()
})
... | true |
683ad8be0903fa9919ce5604a481158e8a95ae61 | Rust | n-arms/parse-inline | /src/parser/parser.rs | UTF-8 | 1,685 | 3.5625 | 4 | [
"MIT"
] | permissive | use std::fmt;
use crate::parser::or_else::OrElse;
use crate::parser::many::Many;
use crate::parser::and::And;
#[derive(Debug, Eq, PartialEq)]
pub struct ParserError {
message: String
}
impl ParserError {
#[allow(dead_code)]
pub fn new(message: String) -> ParserError {
ParserError{ message }
}
... | true |
ad3a3f806ac8e08ef23b7b765dcb0ec3f6e6fb36 | Rust | marslabtron/Minions | /src/mcore/item.rs | UTF-8 | 2,214 | 3 | 3 | [] | no_license | /*
* @Author: BlahGeek
* @Date: 2017-04-19
* @Last Modified by: BlahGeek
* @Last Modified time: 2017-06-29
*/
use std;
use std::fmt;
use std::sync::Arc;
use mcore::action::{Action, ActionArg};
#[derive(Debug, Clone)]
pub enum Icon {
GtkName(String),
Character{ch: char, font: String},
File(std::path::P... | true |
2f80836c693845760a3178fe2b40ffde4bf89ebd | Rust | kenkoooo/shogiutil-rs | /src/piece/moves.rs | UTF-8 | 3,307 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::{Bitboard, Piece, Square};
fn generate_moves(
from: &Square,
occupied: &[Bitboard],
result: &mut Vec<Square>,
d_rank: i8,
d_file: i8,
one: bool,
) {
let mut next_rank = from.rank as i8 + d_rank;
let mut next_file = from.file as i8 + d_file;
while 1 <= next_rank && next_ra... | true |
b781388b90d7305fda29f57b0f4962687ded8e46 | Rust | nathanmcmillan/scroll-and-sigil-rust | /sigil/src/game/camera.rs | UTF-8 | 711 | 3.234375 | 3 | [] | no_license | use crate::things::thing::Thing;
pub struct Camera {
pub x: f32,
pub y: f32,
pub z: f32,
pub rx: f32,
pub ry: f32,
pub radius: f32,
}
impl Camera {
pub fn new(x: f32, y: f32, z: f32, rx: f32, ry: f32, radius: f32) -> Self {
Camera { x, y, z, rx, ry, radius }
}
pub fn updat... | true |
189dae3ec10168dac7c01631c2f8754e59a04101 | Rust | mesosphere/star | /src/probe/status/mod.rs | UTF-8 | 1,482 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
pub mod client;
pub struct Status {
pub targets: Vec<Target>,
}
pub struct Target {
pub url: String,
pub reachable: bool,
}
pub struct StatusCache {
state: HashMap<String, bool>,
}
impl StatusCache {
pub fn new(target_urls: &Vec<String>) -> StatusCache {
l... | true |
b5186b2b86bea9fe1e5f54196818d2a6147de52c | Rust | LongJohnCoder/raptorq | /src/matrix.rs | UTF-8 | 41,075 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use crate::octet::Octet;
use crate::octets::fused_addassign_mul_scalar;
use crate::octets::{add_assign, count_ones_and_nonzeros, mulassign_scalar};
use crate::util::get_both_indices;
use std::cmp::{min, Ordering};
pub struct KeyIter {
sparse: bool,
dense_index: usize,
dense_end: usize,
sparse_rows: Opt... | true |
b9fa7ee1266ecbe832d7c41602c1298164c974ad | Rust | Maxxxxz/Kestrel-Engine | /src/input.rs | UTF-8 | 26,549 | 3.234375 | 3 | [] | no_license | use num_traits::WrappingShl;
use glfw::{Action, Context, Key, MouseButton};
// create consts for each key to properly modify the inputstate unsigned integers
// Input States go here
pub struct InputState
{
// Perhaps instead of keeping bools for each control
// I could simply modify and access an array for
... | true |
0fbe5f3185f5481ed71a03e111d4e7e9cfd7c6d5 | Rust | slpdex/cashcontracts-rs | /src/outputs.rs | UTF-8 | 5,567 | 2.59375 | 3 | [] | no_license | use crate::address::Address;
use crate::unsigned_tx::{Output, PreImage};
use crate::tx::TxOutput;
use crate::script::{Script, Op, OpCodeType};
use crate::hash::hash160;
use byteorder::{BigEndian, WriteBytesExt};
#[derive(Clone, Debug)]
pub struct P2PKHOutput {
pub value: u64,
pub address: Address,
}
pub stru... | true |
7dfe1267989cd5156d135967d4574911795958b7 | Rust | ischeinkman/MediaSync | /src/messages.rs | UTF-8 | 4,022 | 2.53125 | 3 | [] | no_license | use super::DynResult;
use std::time::SystemTime;
mod sync;
use crate::utils::AbsSub;
use std::ops::Add;
pub use sync::{PlayerPosition, PlayerState, SyncMessage};
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Ord, PartialOrd)]
pub struct TimeStamp {
millis: u64,
}
impl TimeStamp {
pub fn now() -> TimeStamp... | true |
1998604d4f0fc490430e3f7672ad4f674d1a1da8 | Rust | wagnerf42/kvik | /src/schedulers/adaptive.rs | UTF-8 | 3,414 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use crate::small_channel::small_channel;
pub(crate) struct AdaptiveScheduler;
pub(crate) fn block_sizes(lower: usize, upper: usize) -> impl Iterator<Item = usize> {
std::iter::successors(Some(lower), move |old: &usize| {
if *old >= upper {
Some(upper)
} else {
... | true |
b82f823d9c5d6f0d878531d994a220c9552d9ad5 | Rust | fatalbanana/stegos | /wallet/src/error.rs | UTF-8 | 2,321 | 2.578125 | 3 | [
"MIT"
] | permissive | //! Wallet - Errors.
//
// Copyright (c) 2018 Stegos AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, mo... | true |
0258ec0eaf64081ddafe9cbcea176cb9487151d0 | Rust | TyOverby/unreliable-message | /examples/transfer.rs | UTF-8 | 1,975 | 2.84375 | 3 | [] | no_license | extern crate unreliable_message;
use unreliable_message::network::ReceiverFilter;
use std::net::UdpSocket;
fn get_sockets() -> (String, String) {
const LOCALHOST: &'static str = "127.0.0.1";
let mut args = std::env::args();
args.next(); // drop how.
let port_1: u16 = args.next().expect("Expected port ... | true |
38a82716ee0a5d3d13e4f6e0915750fc14df80c2 | Rust | Mingun/rust-oci | /src/types.rs | UTF-8 | 14,715 | 2.734375 | 3 | [] | no_license | //! Перечисляемые типы данных, используемые при работе с библиотекой
use std::u32;
/// Возможные типы данных базы данных
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[allow(deprecated)]// Позволяем deprecated внутри перечисления из-за https://github.com/rust-lang/ru... | true |
a31144ed6872de6668f76ea7544d721c67f13443 | Rust | aturon/chalk | /chalk-rust/src/solve/infer/quantify.rs | UTF-8 | 4,916 | 2.90625 | 3 | [
"BSD-3-Clause",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"NCSA",
"MIT",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"Unlicense"
] | permissive | use errors::*;
use fold::{Fold, Folder, Shifter};
use ir::*;
use super::{InferenceTable, TyInferenceVariable,
KrateInferenceVariable, LifetimeInferenceVariable, ParameterInferenceVariable};
use super::ty_var::TyInferenceValue;
use super::krate_var::KrateInferenceValue;
impl InferenceTable {
/// Given ... | true |
c718b5f02cb4ab21b7cdd2a9285167096adbc43f | Rust | jlkiri/rust-sdlang | /src/scanner.rs | UTF-8 | 13,708 | 3.34375 | 3 | [] | no_license | use std::iter::Peekable;
use std::str::CharIndices;
type Index = usize;
type Line = usize;
type Char = (Index, char);
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum Token {
True(usize, usize, Line),
False(usize, usize, Line),
Null(usize, usize, Line),
Equal(usize, usize, Line),
Semicolon(usize,... | true |
5cfa8dca61fd0652960b1cded04a73b0a7772848 | Rust | IThawk/rust-project | /rust-master/src/test/ui/feature-gates/feature-gate-non_ascii_idents.rs | UTF-8 | 664 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | extern crate core as bäz; //~ ERROR non-ascii idents
use föö::bar; //~ ERROR non-ascii idents
mod föö { //~ ERROR non-ascii idents
pub fn bar() {}
}
fn bär( //~ ERROR non-ascii idents
bäz: isize //~ ERROR non-ascii idents
) {
let _ö: isize; //~ ERROR non-ascii idents
match (1, 2) {
(_ä, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.