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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d56ca2024fee54c258ea6a79bcf2d353d83ed3ed | Rust | vipulkit/sri-delhi-rust-libcss | /test/testcases-ryanc/libcss/number.rs | UTF-8 | 4,197 | 2.765625 | 3 | [] | no_license | extern mod std;
extern mod css;
extern mod wapcaplet;
use css::parse::properties::common::*;
use wapcaplet::*;
fn main() {
debug!("number");
// number(~"data/number/number.dat");
// let i = print_css_fixed(1);
}
fn number(file_name: ~str) {
let r:@Reader = io::file_reader(&Path(file_nam... | true |
83f3abd210a6be0f2b5470b29b21363fe68ad7ea | Rust | GSam/rust-refactor | /tests/variable/working_mut_tuple_let3_out.rs | UTF-8 | 62 | 2.546875 | 3 | [] | no_license | fn main() {
let (a, mut x) = (1, 2);
let c = a + x;
}
| true |
b1ce81a07e288952df99ce6084371d66255b2ee7 | Rust | tonmanna/RustLearningFollowBookBeginer | /convertor/src/files.rs | UTF-8 | 270 | 2.578125 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, prelude::*, BufReader};
pub fn readfile_sync() -> io::Result<()> {
let file = File::open("foo.txt")?;
let reader = BufReader::new(file);
for line in reader.lines() {
println!("{}", line?);
}
Ok(())
}
| true |
9744f1173721d4d1e7a3f74ae89093b1b938d91c | Rust | Eliak/lucene_vector | /rust/src/unaligned.rs | UTF-8 | 3,923 | 2.5625 | 3 | [] | no_license | use std::collections::HashMap;
use std::sync::{Arc, RwLock};
use jni::objects::JObject;
use jni::sys::jfloatArray;
use jni::JNIEnv;
use packed_simd::{f32x16, f32x4, f32x8};
// type Cache = Arc<RwLock<HashMap<i32, Arc<Vec<f32>>, BuildHasherDefault<FNV1aHasher32>>>>;
// type Cache = Arc<RwLock<HashMap<i32, Arc<Vec<f32>... | true |
d2be54e2b2cdd54c284e8e81ee154d891c6f35c7 | Rust | masinc/checkip-rust | /src/ip_addr_client/http_bin.rs | UTF-8 | 2,600 | 2.640625 | 3 | [] | no_license | #[cfg(test)]
use mockall::{mock, predicate::*};
use std::net::IpAddr;
use super::IpAddrClient;
use async_trait::async_trait;
use anyhow::Result;
use reqwest::Client;
pub struct HttpBin {
url: &'static str,
}
const URL_HTTP: &str = "http://httpbin.org/ip";
const URL_HTTPS: &str = "https://httpbin.org/ip";
imp... | true |
fe73f223a313e5a617fd20efd09256649c35600c | Rust | slhmy/online_judge | /src/judge_server/utils/filter.rs | UTF-8 | 777 | 2.625 | 3 | [] | no_license | pub fn language_filter(language: &str) -> bool {
match language {
"c" => true,
"cpp" => true,
"java" => true,
"py2" => true,
"py3" => true,
_ => false,
}
}
pub fn judge_type_filter(judge_type: &str) -> bool {
match judge_type {
"OI" => true,
"... | true |
7e99edad6d63738469c861a22bf5ecdeead91b72 | Rust | frilli31/MPQS | /src/main.rs | UTF-8 | 2,493 | 3.15625 | 3 | [] | no_license | #![allow(non_snake_case)]
use clap::{App, Arg};
use rug::Integer;
use rug::integer::IsPrime;
use MPQS::*;
pub fn main() {
let app = App::new("MPQS")
.version("1.0")
.author("Luca Allegro <luca.all1996@gmail.com>")
.about("Rust implementation of Multi-polinomial Quadratic Sieve, an algorit... | true |
509fdb25347651cb4bd28ecd0b0ba7d7db43389f | Rust | isgasho/twang | /src/lib.rs | UTF-8 | 3,190 | 2.859375 | 3 | [
"Apache-2.0",
"Zlib",
"MIT"
] | permissive | // Copyright (c) 2018-2020 Jeron Aldaron Lau
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>, the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, or the ZLib
// license <LICENSE-ZLIB or https://www.zlib.net/zlib_license.html> at
... | true |
2ac07140e50c4f099a1e9e80e5e96d29736a715e | Rust | TyPR124/winpipe | /src/lib.rs | UTF-8 | 4,546 | 2.734375 | 3 | [] | no_license | //! A tiny library wrapping Windows Pipes API
// #![warn(missing_docs)]
#[cfg(test)]
mod tests;
use winapi::um::{
namedpipeapi::{CreatePipe, /* DisconnectNamedPipe, */ PeekNamedPipe},
fileapi::{ReadFile, FlushFileBuffers, WriteFile},
handleapi::{CloseHandle, DuplicateHandle},
processthreadsapi::GetCu... | true |
b66039620dab02a1f20c889ae32eea957086cabe | Rust | udzura/fork-wait-example | /src/main.rs | UTF-8 | 779 | 2.90625 | 3 | [] | no_license | use nix::sys::wait::waitpid;
use nix::unistd::{fork, ForkResult};
use std::thread::sleep;
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Hello, world!");
for _ in 0..5 {
match unsafe { fork()? } {
ForkResult::Parent { child } => {
p... | true |
103357122b5c79676d9ed7c26952935d8459a511 | Rust | emilio/lyon | /cli/src/flatten.rs | UTF-8 | 1,923 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use commands::FlattenCmd;
use lyon::svg::parser;
use lyon::path;
use lyon::path_builder::*;
use lyon::path_iterator::*;
use lyon::events::FlattenedEvent;
use std::io;
#[derive(Debug)]
pub enum FlattenError {
Io(io::Error),
Parse,
}
impl ::std::convert::From<::std::io::Error> for FlattenError {
fn from(err... | true |
a3993018a73ec78745b79d3d778cfbacab9f3d99 | Rust | topecongiro/openrr | /openrr-apps/src/robot_command.rs | UTF-8 | 9,241 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use crate::Error as OpenrrAppsError;
use async_recursion::async_recursion;
use log::info;
use openrr_client::isometry;
use std::{
error::Error,
fs::File,
io::{BufRead, BufReader},
path::PathBuf,
};
use structopt::StructOpt;
use crate::{RobotClient, RobotConfig};
#[derive(StructOpt, Debug)]
#[structopt... | true |
7d51218c3e9dc0994fd2bd82b63bda49b99b673e | Rust | shadercoder/hanamaru-renderer | /src/scene.rs | UTF-8 | 13,563 | 3.015625 | 3 | [] | no_license | use config;
use vector::{Vector3, Vector2};
use material::{Material, PointMaterial, SurfaceType};
use camera::Ray;
use texture::ImageTexture;
use math::{equals_eps, modulo};
use color::Color;
use bvh::{BvhNode, Aabb, intersect_polygon};
#[derive(Debug)]
pub struct Intersection {
pub position: Vector3,
pub dist... | true |
9fafe4e13a8c3f977c012ede681063a7ec4ee403 | Rust | galenelias/AdventOfCode_2015 | /src/Day5/mod.rs | UTF-8 | 1,330 | 3 | 3 | [] | no_license | use std::io::{self, BufRead};
use itertools::Itertools;
use std::collections::HashMap;
fn part1 (lines : &[Vec<char>]) -> usize {
lines.iter().filter(|line| {
let unique_vowels = line.iter().filter(|ch| match **ch { 'a'|'e'|'i'|'o'|'u' => true, _ => false }).count();
let any_repeat = line.windows(2).any(|w| w[0] ... | true |
81931d9190cf2a7dbedb192095ac6ace7bd718c9 | Rust | cosim/tikv | /src/storage/txn/shard_mutex.rs | UTF-8 | 1,790 | 3.203125 | 3 | [] | no_license | use std::sync::{Mutex, MutexGuard};
use std::hash::{Hash, SipHasher, Hasher};
pub struct ShardMutex {
mutex: Vec<Mutex<()>>,
size: usize,
}
impl ShardMutex {
pub fn new(size: usize) -> ShardMutex {
ShardMutex {
mutex: (0..size).map(|_| Mutex::new(())).collect(),
size: size,... | true |
270948bed4c0bec1530dc8191a0a98721230be62 | Rust | chris-zen/hero-synth | /studio/src/engine/mod.rs | UTF-8 | 4,576 | 2.640625 | 3 | [
"MIT"
] | permissive | pub mod events;
pub mod types;
use std::sync::mpsc::{Sender, Receiver};
use std::sync::atomic::{Ordering, AtomicBool};
use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle};
use hero_core::types::{SampleRate, Tempo, DEFAULT_TEMPO};
use hero_synth::synth::Synth as HeroSynth;
use audio::processing::{AudioOu... | true |
67c1f779e6645ec9741adaa8efc2160a0c63ec74 | Rust | ferjm/registration_server | /src/routes.rs | UTF-8 | 3,979 | 2.765625 | 3 | [] | no_license | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use db::{ Db, FindFilter, Record };
use iron::headers::{ AccessControlAllowOrigin, ContentType };
use iron::prelud... | true |
a27fbefe0d556819b52a8991c5510ed2ea4d081c | Rust | udoprog/ptscan | /crates/ptscan/src/value_expr/value_op.rs | UTF-8 | 987 | 3.40625 | 3 | [
"MIT",
"Apache-2.0",
"CC-BY-SA-3.0"
] | permissive | use crate::Value;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ValueOp {
#[serde(rename = "add")]
Add,
#[serde(rename = "sub")]
Sub,
#[serde(rename = "mul")]
Mul,
#[serde(rename = "div")]
Div,
}
i... | true |
ce7a58101b13e2e7e7f930c0812c15cd8cb6f8f1 | Rust | leod/rendology | /src/fxaa/shaders.rs | UTF-8 | 13,209 | 2.875 | 3 | [
"MIT"
] | permissive | //! Fast approximate anti-aliasing (FXAA) shader.
//!
//! Heavily inspired by:
//! http://blog.simonrodriguez.fr/articles/30-07-2016_implementing_fxaa.html#ref3
//!
//! See also the following for what seems to be a reference implementation:
//! https://gist.github.com/kosua20/0c506b81b3812ac900048059d2383126
//!
//! I ... | true |
027920a8a07c21cee73ab6840402186cee8590a7 | Rust | vibhoothi/potato_rust | /src/formatting.rs | UTF-8 | 1,900 | 3.859375 | 4 | [] | no_license | use std::fmt::{self, Formatter, Display};
struct City
{
name: &'static str,
lat: f32,
long: f32,
}
impl Display for City
{
fn fmt(&self, f:&mut Formatter) -> fmt::Result
{
let lat_c = if self.lat >=0.0
{
'N'
... | true |
365242aa4c18cd58f6a534d7743f9d83f43b3e88 | Rust | nickik/richdb | /src/main.rs | UTF-8 | 5,318 | 2.53125 | 3 | [] | no_license | #![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_derive)]
#![feature(integer_atomics)]
extern crate rpds;
extern crate rocket;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate rmp_serde as rmps;
extern crate rocksdb;
use rocksdb::{DB, Writable};
use serde::{Deserialize, Serial... | true |
fb5d859896eb257fb500c90cea107390655c1c2d | Rust | kubkon/exercism-exercises | /rust/hello-world/src/lib.rs | UTF-8 | 196 | 3.109375 | 3 | [] | no_license | pub fn hello(name: Option<&str>) -> String {
let hello = "Hello";
match name {
None => format!("{}, World!", hello),
Some(name) => format!("{}, {}!", hello, name),
}
}
| true |
444edc3e897a09c04922c16c986ac482dd5008dc | Rust | jashka34/myprojecteuler | /problem010/rust/src/prime.rs | UTF-8 | 2,709 | 3.640625 | 4 | [] | no_license |
pub fn is_prime(n: u64) -> bool {
//println!("------------------");
//println!("is_prime: {}", n);
if n == 2 {
return true;
}
if n % 2 == 0 {
return false;
} else {
let sq = (n as f64).sqrt();
let maxi: u64 = (sq as u64) + 1;
//let mut max: i32 = 0;
... | true |
6821a7d196a4569b24c57e0d1894a42ebbc900d2 | Rust | ajsutton/beacon-fuzz | /beaconfuzz_v2/src/bin/diff_deposit.rs | UTF-8 | 4,170 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[macro_use]
extern crate honggfuzz;
extern crate types;
extern crate walkdir;
extern crate ssz;
extern crate ssz_derive;
use ssz::Decode;
use types::{BeaconState, MainnetEthSpec};
use std::fs::File;
use std::io;
use std::io::Read;
use std::process;
use walkdir::WalkDir;
use std::fs::OpenOptions;
use std::io::pr... | true |
2ec0cd9174525c3c2c33bc6cecc217478416b8a9 | Rust | remexre/csci5607 | /asgn2/src/renderable/triangle.rs | UTF-8 | 1,752 | 3.34375 | 3 | [] | no_license | use cgmath::{dot, Vector3};
use material::Material;
use ray::Ray;
use renderable::Renderable;
/// A triangle.
#[derive(Clone, Debug, PartialEq)]
pub struct Triangle {
/// The vertices of the triangle.
pub vertices: (Vector3<f32>, Vector3<f32>, Vector3<f32>),
/// The normal vector from the triangle.
p... | true |
ccbdc27058a360a5dfe284918dd07224264a0290 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/tuf-0.3.0-beta11/src/format_hex.rs | UTF-8 | 516 | 2.65625 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use data_encoding::HEXLOWER;
use serde::{self, Deserialize, Deserializer, Serializer};
use std::result::Result;
pub fn serialize<S>(value: &[u8], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&HEXLOWER.encode(value))
}
pub fn deserialize<'de, D>(deserializer: D) -> ... | true |
18c555c1229af67ed7acf4e203c22512c36bd8ea | Rust | Andreas-Edling/triangulator | /src/delaunay_inc/ordered_pair.rs | UTF-8 | 454 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::types::TriIdx;
#[derive(Hash, PartialEq, Eq, Clone, Debug)]
pub struct OrderedPair {
a: TriIdx,
b: TriIdx,
}
impl OrderedPair {
pub fn new(first: TriIdx, second: TriIdx) -> Self {
if first > second {
OrderedPair {
a: second,
b: first,
... | true |
8bd243755d1dad4281b5de6feb62d4b83970663a | Rust | PatrykStronski/gomoku | /src/user_turn.rs | UTF-8 | 1,255 | 3.265625 | 3 | [] | no_license | use std::io::{stdin, stdout, Write};
fn into_usize(input: Vec<&str>) -> [usize; 2] {
let x: usize = input[0].parse().unwrap();
let y: usize = input[1].parse().unwrap();
return [x, y];
}
fn invalid_coordinates(out_usize: [usize; 2]) -> bool {
let condition =
out_usize[0] >= 0 && out_usize[0] < ... | true |
d98442339374bdd56b680c877d554f6ab72caa26 | Rust | sdbondi/tower-examples | /examples/flooder.rs | UTF-8 | 1,935 | 2.859375 | 3 | [] | no_license | use futures::future::JoinAll;
use futures::{Future, Poll};
use std::io::Write;
use std::iter::repeat_with;
use std::marker::PhantomData;
use tokio::net::TcpStream;
use tower::ServiceBuilder;
use tower_layer::Layer;
use tower_service::Service;
struct RepeatService<S> {
n: usize,
service: S,
}
impl<S, TReq> Ser... | true |
926eaa8bc9eb5956f67c1737a310a13c5ee32305 | Rust | Bastczuak/Doom | /src/system/view.rs | UTF-8 | 3,610 | 2.8125 | 3 | [] | no_license | use crate::angle::Angle;
use crate::component::*;
use crate::wad::node::Node;
use crate::wad::seg::Seg;
use crate::wad::ssector::SSector;
use crate::wad::vertex::{Vertex, VisibleVertexes};
use specs::prelude::*;
use std::f32::consts::PI;
struct ViewFinder<'a> {
nodes: &'a Vec<Node>,
segs: &'a Vec<Seg>,
ssectros:... | true |
5526965570c1f0f6c5bdb374a8663136af87df12 | Rust | Nimpruda/boa | /boa/src/builtins/function/mod.rs | UTF-8 | 18,061 | 3.03125 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! This module implements the global `Function` object as well as creates Native Functions.
//!
//! Objects wrap `Function`s and expose them via call/construct slots.
//!
//! `The `Function` object is used for matching text with a pattern.
//!
//! More information:
//! - [ECMAScript reference][spec]
//! - [MDN docum... | true |
009384c02c2372112ea424b3ad98a4d9d575dfb5 | Rust | Adil7/PokerRust | /RustLab.rs | UTF-8 | 1,061 | 3.703125 | 4 | [] | no_license | fn main(){
let s1 = String::from("this is a string ");
let s2 = String::from("concat");
let s3 = string_concat(&s1, &s2);
println!("{}", s3);
let nums = [1.5, 2.7, 3.6, 4.9, 5.8];
let range_tuple = (0, 4);
let avg = sub_array_average(&nums, range_tuple);
println!("Average: {}", avg);
... | true |
3a093bf0b2e06a20b0b8833bc860c60990aaefc6 | Rust | JoaoBaptMG/PathRenderingLabRs | /path-processor/src/path/subdivision_structs.rs | UTF-8 | 2,939 | 3.140625 | 3 | [
"MIT"
] | permissive | //------------------------------------------------------------------------------
// subdivision_structs.rs
//------------------------------------------------------------------------------
// Provides the structures to subdivide the generated simple faces in triangles,
// curve triangles and double curve triangles
//---... | true |
6273e2202912d870d85e15699d32bdaf780ac725 | Rust | SecretPocketCat/bevy_asset_loader | /bevy_asset_loader/examples/two_collections.rs | UTF-8 | 2,604 | 2.828125 | 3 | [
"MIT",
"CC-BY-3.0"
] | permissive | use bevy::prelude::*;
use bevy_asset_loader::{AssetCollection, AssetLoader};
const PLAYER_SPEED: f32 = 5.;
fn main() {
let mut app = App::build();
AssetLoader::new(MyStates::AssetLoading, MyStates::Next)
.with_collection::<TextureAssets>()
.with_collection::<AudioAssets>()
.build(&mut ... | true |
24b93648daa571a4d15190af525901785fad12f4 | Rust | frondeus/Horust | /tests/section_general.rs | UTF-8 | 3,914 | 2.5625 | 3 | [
"MIT"
] | permissive | use assert_cmd::prelude::*;
use predicates::str::{contains, is_empty};
use tempdir::TempDir;
#[allow(dead_code)]
mod utils;
use nix::sys::signal::{kill, Signal};
use std::thread::sleep;
use std::time::Duration;
use utils::*;
fn test_single_output_redirection(stream: &str, to: &str) {
let (mut cmd, temp_dir) = get... | true |
77cb31d24864f5241540c6064b12ee2914616a8c | Rust | bpowers1215/MoneyMap | /api/src/common/utilities/url.rs | UTF-8 | 1,166 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | // src/common/utilities/url.rs
/// Utilities for URLs
// Import
// External
use ::regex::Regex;
#[derive(Clone, Debug)]
pub struct SortParam{
pub field: String,
pub direction: i32
}
/// Get Sort Param from URL string
///
/// # Arguments
/// * `sort` - A String slice of the "sort" property of a URL query Str... | true |
4c729ea3dc55b905092ab6baf820991aa88569cd | Rust | helphi/learning.rust | /hello.rs | UTF-8 | 952 | 4.25 | 4 | [] | no_license | /// 以三个斜杠开头的注释为文档注释,支持 Markdown,会生成 HTML 文档
/// 使用以下指令运行程序
///
/// ```bash
/// rustc main.rs
/// ./main
/// ```
fn main() {
let x = hello();
let y = {
"word" // 结尾没有分号,则它是一个表达式,会返回值给变量 y
};
println!("{} {}", x, y);
}
fn hello() -> &'static str { // 此处使用 `'static` 指明 `&str` 类型的返回值的生命周期为永久,因为返回... | true |
894a0962be5339974a9f049c93348467581a238f | Rust | fero23/bytevec | /tests/lib.rs | UTF-8 | 3,890 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[macro_use]
extern crate bytevec;
use bytevec::{ByteEncodable, ByteDecodable};
#[test]
fn test_serialize_vec() {
bytevec_decl! {
#[derive(PartialEq, Eq, Debug)]
struct Employee {
id: u32,
profile: Profile,
dept: String
}
#[derive(Partia... | true |
db720992d68576499c80cd021fad9670ec5a92de | Rust | Phala-Network/phala-blockchain | /vendor/ring/src/aead/unbound_key.rs | UTF-8 | 2,486 | 2.53125 | 3 | [
"OpenSSL",
"MIT",
"ISC",
"LicenseRef-scancode-mit-taylor-variant",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2015-2021 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI... | true |
990de98d6b23233c6d754eacac5df9eb9e61ea27 | Rust | esheldon/rustcode | /quickintro.rs | UTF-8 | 375 | 3.453125 | 3 | [] | no_license | fn main() {
let mut x = vec!["Hello", "world"];
// rust has move symantics by default, so we need
// to use clone() to get a copy. If we didn't copy
// then the push would be a compile error
let y = &x[0].clone();
x.push("foo");
// this will get a reference that lives within the scope
... | true |
2a8485817f07c7d0d5f800328904e5dd38a9be9a | Rust | Orca-bit/DataStructureAndAlgorithm | /src/greedy/_991_broken_calculator.rs | UTF-8 | 783 | 3.421875 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn broken_calc(start_value: i32, mut target: i32) -> i32 {
let mut ops = 0;
while start_value < target {
if target & 1 == 0 {
target >>= 1;
} else {
target += 1;
}
ops += 1;
... | true |
269a105349b63f3fe78c8b816ce11d033de629b7 | Rust | RNGKing/Jelopi | /src/instruction.rs | UTF-8 | 2,928 | 3.390625 | 3 | [
"MIT"
] | permissive | use crate::opcode::OpCode;
use std::fs::{self, File};
use std::io::{self, BufRead};
use std::path::Path;
use std::fmt;
use json::{self, JsonValue};
use std::error::Error;
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>,
{
let file = File::open(filename)?;
Ok(io... | true |
aa48f67c949331c62714b10b28de4e5350c21296 | Rust | BartMassey/advent-of-code-2020 | /day19/soln.rs | UTF-8 | 3,518 | 3 | 3 | [
"MIT"
] | permissive | // This program is licensed under the "MIT License".
// Please see the file LICENSE in this distribution
// for license terms.
//! Advent of Code Day 19.
//! Bart Massey 2020
use std::collections::HashMap;
use std::io::{stdin, Read};
use aoc_reparse::*;
type Grammar = HashMap<u64, Prod>;
type Message = Vec<char>;... | true |
2996174624af65fe0fa2108a20598035cf436094 | Rust | akash-fortanix/fancy-garbling | /src/util.rs | UTF-8 | 2,078 | 3.15625 | 3 | [] | no_license | use rand::Rng;
use crate::numbers;
pub fn u128_to_bytes(x: u128) -> [u8;16] {
unsafe {
std::mem::transmute(x)
}
}
pub fn bytes_to_u128(bytes: [u8;16]) -> u128 {
unsafe {
std::mem::transmute(bytes)
}
}
////////////////////////////////////////////////////////////////////////////////
// ... | true |
ffa9a79b9ccea22e12acd81431f99fc9ba36f90b | Rust | edvorg/payme | /src/payme/pdf/mod.rs | UTF-8 | 1,299 | 2.921875 | 3 | [
"MIT"
] | permissive | extern crate reqwest;
use self::reqwest::Client;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::Path;
#[derive(Clone)]
pub enum PdfType {
Invoice,
Receipt,
}
pub fn get_pdf_title(pdf_type: PdfType) -> String {
match pdf_type {
PdfType::Invoice => "invoice".to_string(),
... | true |
b557f43c5a24ec9d21e1a9a382dd3e5e7a479be6 | Rust | BurntSushi/bstr | /src/bstr.rs | UTF-8 | 2,892 | 3.6875 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unicode"
] | permissive | use core::mem;
#[cfg(feature = "alloc")]
use alloc::boxed::Box;
/// A wrapper for `&[u8]` that provides convenient string oriented trait impls.
///
/// If you need ownership or a growable byte string buffer, then use
/// [`BString`](struct.BString.html).
///
/// Using a `&BStr` is just like using a `&[u8]`, since `BS... | true |
c9ad4ecbe8c2647e0d7bb0bdc38d0859b14b1c52 | Rust | DogLi/rn | /src/utils/toml_parser.rs | UTF-8 | 3,348 | 3.109375 | 3 | [
"MIT"
] | permissive | use toml;
use errors::*;
use std::fmt::Debug;
use std::path::Path;
use utils::util::load_file;
use std::cmp::PartialEq;
use shellexpand::tilde;
use std::env::current_dir;
#[derive(Debug, Deserialize)]
pub struct GlobalConfig {
pub global_user: String,
pub global_password: Option<String>,
pub global_key: ... | true |
c354b7455371bf3a2af16def0e45ced917c4d43f | Rust | IThawk/rust-project | /rust-master/src/test/ui/borrowck/borrowck-migrate-to-nll.rs | UTF-8 | 1,008 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // This is a test of the borrowck migrate mode. It leverages #27282, a
// bug that is fixed by NLL: this code is (unsoundly) accepted by
// AST-borrowck, but is correctly rejected by the NLL borrowck.
//
// Therefore, for backwards-compatiblity, under borrowck=migrate the
// NLL checks will be emitted as *warnings*.
/... | true |
01de8e346a09a7b45ef490a7db9e855ffdf33277 | Rust | rmeno12/flowlang | /flow/src/main.rs | UTF-8 | 428 | 2.65625 | 3 | [] | no_license | use std::{env, fs};
mod ast;
// mod check;
mod token;
fn main() {
let args: Vec<String> = env::args().collect();
let code = fs::read_to_string(&args[1]).expect("Couldn't open file");
let toks = token::tokenize(code);
let ast = ast::make_ast(&toks);
match ast {
Ok(_) => {
print... | true |
10b726ce8aa165f8e6ed30ddcbb41c2529849748 | Rust | TubeRecorder/web-middleware | /src/server/db/db_connection.rs | UTF-8 | 697 | 2.5625 | 3 | [
"MIT"
] | permissive | use log::info;
use sqlx::postgres::{
PgConnectOptions,
PgPool,
PgPoolOptions,
};
pub async fn db_connection(
host: String,
port_number: u16,
database_name: String,
username: String,
password: String,
) -> Result<PgPool, sqlx::Error> {
info!(
"connecting to postgres://{}:{}@{}:{}/{}",
&userna... | true |
17bc17bd62af1a1e363574dfa6fe7395c77e0bb7 | Rust | Ratysz/goods | /src/channel.rs | UTF-8 | 2,718 | 2.890625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use {
alloc::vec::Vec,
core::{
future::Future,
mem::swap,
pin::Pin,
task::{Context, Poll, Waker},
},
maybe_sync::{Mutex, Rc},
};
/// Reciver for spin-lock based channel.
pub(crate) struct Receiver<T> {
inner: Rc<Mutex<Queue<T>>>,
}
impl<T> Receiver<T> {
pub(crat... | true |
d8e6a6f59b3684e8b110ac945e16c975f9dfd9aa | Rust | devalain/lycherel | /src/main.rs | UTF-8 | 1,508 | 3.25 | 3 | [] | no_license | use std::cmp::{PartialEq, PartialOrd};
use std::fmt::{Debug, Display};
use std::ops::{AddAssign, DivAssign, MulAssign, Rem};
use rug::Integer;
trait Num:
Clone
+ Rem<Output = Self>
+ AddAssign
+ MulAssign
+ DivAssign
+ PartialOrd
+ Display
+ Debug
... | true |
c9079c6eac7961b9c605eb71c394081a8354261e | Rust | wasniksudesh/Rust | /Basic commands compilation/src/structs.rs | UTF-8 | 406 | 3.6875 | 4 | [] | no_license | struct Person (String,String);
impl Person{
fn single(one:&str,two:&str)->Person{
Person(
one.to_string(),two.to_string())
}
fn fullname(&self)->String{
format!("{},{}",self.0,self.1)
}
}
pub fn run(){
let var1 = Person::single("Yeah","NO");
println!("This si new an... | true |
6ecb51999f3f1adaa35b865a274724397f742938 | Rust | zalkikar/DB-Final | /server/src/models/genmodelin.rs | UTF-8 | 1,064 | 2.734375 | 3 | [] | no_license |
use sqlx::sqlite::SqliteRow;
use sqlx::{FromRow, Row};
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Clone)]
pub struct GenModelIn {
pub Age: Option<i32>,
pub Gender: Option<String>,
pub Weight: Option<i32>,
pub Height: Option<i32>,
pub City: Option<i32>,
pub Country: Option<i32>,
... | true |
53b6babb3c987c272003b1c53c346e321b7e8c0d | Rust | derekdreery/w3c-idl-extractor | /src/lib.rs | UTF-8 | 3,109 | 2.828125 | 3 | [] | no_license | #[macro_use] extern crate html5ever;
#[macro_use] extern crate failure_derive;
extern crate failure;
use std::io;
use std::default::Default;
use std::string::String;
use std::ascii::AsciiExt;
use html5ever::parse_document;
use html5ever::rcdom::{NodeData, RcDom, Handle};
use html5ever::tendril::TendrilSink;
#[deriv... | true |
e9c63e3b7996b1553518cbe1d7bb7c5fd88b6e79 | Rust | BTAutist/MemScan | /src/value_scanner.rs | UTF-8 | 2,010 | 2.609375 | 3 | [] | no_license | use crate::pbar::PBar;
use memflow::error::*;
use memflow::mem::VirtualMemory;
use memflow::types::{size, Address};
#[derive(Default)]
pub struct ValueScanner {
matches: Vec<Address>,
mem_map: Vec<(Address, usize)>,
}
impl ValueScanner {
pub fn reset(&mut self) {
self.matches.clear();
self... | true |
395f94132560bf36a956dbc29d62185613cde970 | Rust | pedantic79/Exercism | /rust/wordy/src/lib.rs | UTF-8 | 3,269 | 3.9375 | 4 | [] | no_license | enum Operation {
Add,
Sub,
Mul,
Div,
Pow,
}
struct Tokens<'a>(std::iter::Peekable<std::str::SplitWhitespace<'a>>);
impl<'a> Tokens<'a> {
pub fn new(input: &'a str) -> Self {
let p = input.split_whitespace().peekable();
Self(p)
}
fn check(&mut self, word: &str) -> Optio... | true |
45de26fedede2d77b3a0016b4f7b4f6a31abc1fe | Rust | Spxg/DSandA | /alds1_1_d_maxinum_profit.rs | UTF-8 | 697 | 3.171875 | 3 | [] | no_license | fn main() {
let mut data = Vec::with_capacity(200000);
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).expect("read error");
let n = buf.trim().parse::<usize>().expect("parse error");
assert!(n <= 200000 && n >= 2);
for _ in 0..n {
let mut buf = String::new();
... | true |
a7f8318aba2d197a3cf200a2fd7f836f5f3e4e50 | Rust | KodrAus/log-enrich | /src/log.rs | UTF-8 | 2,803 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::io::{self, Write};
use stdlog::Record;
use env_logger::Formatter;
use serde::ser::{Serialize, SerializeMap, Serializer};
use current_logger;
use ctxt::Ctxt;
/**
Enriched-property aware log format.
*/
pub fn format() -> impl Fn(&mut Formatter, &Record) -> io::Result<()> {
|buf, record| {
current_... | true |
b969cdaa6e234f415833e2ec9732b45621b0db46 | Rust | jlgerber/jobsyspolice | /src/jspt/errors.rs | UTF-8 | 4,267 | 2.84375 | 3 | [] | no_license | use failure::Fail;
use crate::jspt::State;
use nom;
use std::{io, path::PathBuf};
use ext_regex;
/// The Fail implementation for this crate. All functions that return
/// results should return a JSPTemplateError for the error branch.
#[derive(Debug, Fail, PartialEq, Clone)]
pub enum JSPTemplateError {
#[fail(disp... | true |
03f8701c6886c9a7868e2638103f3affb4a35881 | Rust | ofrank123/AoC2020 | /prob16_1/src/main.rs | UTF-8 | 2,398 | 3.5 | 4 | [] | no_license | extern crate aoc;
#[derive(Debug)]
struct Field {
name: String,
ranges: Vec<(i32, i32)>,
}
impl Field {
fn in_field(&self, val: i32) -> bool {
for (lower, upper) in &self.ranges {
if val >= *lower && val <= *upper {
return true
}
}
false
... | true |
18905149a3c5db182e3a228fe678ed37e116d94c | Rust | seandewar/challenge-solutions | /leetcode/medium/verifying-an-alien-dictionary.rs | UTF-8 | 1,254 | 3.453125 | 3 | [] | no_license | // https://leetcode.com/problems/verifying-an-alien-dictionary
//
// These solutions abuse the Rust standard library's absence of is_sorted_by(), instead using
// sort_unstable_by() to solve this problem by comparing our sorted words with the input words
// (there shouldn't be a difference if input words were already s... | true |
cf7b4c964e30d74a342704bfce98b773f706fc44 | Rust | jamwaffles/trajectories | /trajectories/src/path/path_switching_point.rs | UTF-8 | 563 | 3.125 | 3 | [] | no_license | use super::Continuity;
/// A switching point
#[derive(Debug, Clone, PartialEq)]
pub struct PathSwitchingPoint {
/// Position along the path at which this switching point occurs
pub position: f64,
/// Whether this switching point is discontinuous or not
pub continuity: Continuity,
}
impl PathSwitchingP... | true |
34b411d1d28fff19a06186463f9791106a9aa9c3 | Rust | Jason-Cooke/gluon | /check/src/lib.rs | UTF-8 | 3,509 | 2.578125 | 3 | [
"MIT"
] | permissive | //! The `check` crate is responsible for ensuring that an AST expression is actually a valid
//! program. This currently consits of three larger parts, typechecking, kindchecking and renaming.
//! If an AST passes the checks in `Typecheck::typecheck_expr` (which runs all of theses checks
//! the expression is expected ... | true |
2bc71d9657271eb49886752fb6b747620d28608f | Rust | enso-org/enso | /lib/rust/json-rpc/src/api.rs | UTF-8 | 1,065 | 2.765625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! Module contains entities used by client implementor to describe remote API.
use crate::prelude::*;
use crate::error::RpcError;
use crate::messages::Id;
use crate::messages::Message;
use crate::messages::RequestMessage;
use serde::de::DeserializeOwned;
use serde::Serialize;
// ==============
// === Result ===
... | true |
2ba5ea6e864f8861360a6969d5ef3115f3099c3d | Rust | Robbepop/prophet | /src/mentor/logger.rs | UTF-8 | 1,465 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::time::{SystemTime, Duration};
use mentor::configs::LogConfig;
/// Status during the learning process.
#[derive(Debug, Copy, Clone)]
pub struct Stats {
/// Number of samples learned so far.
pub iterations : u64,
/// Time passed since beginning of the training.
pub elapsed_time: Duration,
/// The lates... | true |
721d1a1ad2f655ef94b15a0da158cf269b65d391 | Rust | rust-bio/rust-htslib | /src/bgzf/mod.rs | UTF-8 | 19,527 | 2.703125 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Manuel Landesfeind, Evotec International GmbH
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//!
//! Module for working with bgzipped file.
//!
use std::ffi;
use std::path::Path;
use ... | true |
dddb86a4fa4ac43c073740917d27e8f3ef79dc16 | Rust | levkk/rust-ruby | /src/lib.rs | UTF-8 | 2,548 | 3.546875 | 4 | [] | no_license | // C types
extern crate libc;
use libc::c_char;
// Foreign functions interface
// CStr = owned by the caller (i.e. Ruby)
// CString = owned by Rust
use std::ffi::{CStr, CString};
// Preserve the function name for calling from outside the library.
#[no_mangle]
// Makes it C compatible.
pub extern "C" fn add(i: i64, j:... | true |
fd04d313f3be169fe4e1d2f1eb3d7c59a509ce95 | Rust | SamirTalwar/advent-of-code | /2019/AOC_16_2.rs | UTF-8 | 3,028 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::fmt;
use std::io;
use std::iter;
use rayon::prelude::*;
mod digits;
mod errors;
type Value = i64;
type Numbers = Vec<Value>;
type Phases = Vec<Vec<(usize, usize, PhaseValue)>>;
#[derive(Debug, Clone, Copy)]
enum PhaseValue {
Positive,
Negative,
}
const REPETITIONS: usize = 10000;
con... | true |
2034a85ddd01737c101200498528c56e340e47d8 | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-12567.rs | UTF-8 | 452 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![feature(slice_patterns)]
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
match (l1, l2) {
//~^ ERROR: cannot move out of type `[T]`, a non-copy slice
//~| ERROR: cannot move out of type `[T]`, a non-copy slice
(&[], &[]) => println!("both empty"),
(&[], &[hd, ..]) | (&[hd, ..], &[])
... | true |
c06e48324f4ca4d7cb8f83b04a44dc8bfb57b46b | Rust | itang/code-world | /rust-for-rubyists/stdin.rs | UTF-8 | 247 | 2.90625 | 3 | [] | no_license | use std::io;
use std::io::BufferedReader;
use std::io::{print, println};
fn main() {
println("INPUT:");
let mut stdin = BufferedReader::new(io::stdin());
for line in stdin.lines() {
println("YOU TYPED:");
print(line.unwrap());
}
} | true |
68b8d2ff2589f548397cdd2e2021635791f2b77c | Rust | seitamuro/atcoder_base90 | /p001/src/main.rs | UTF-8 | 1,388 | 3.078125 | 3 | [] | no_license | use std::io::prelude::*;
use std::io::{self, BufReader};
fn main() {
let stdin = io::stdin();
let reader = BufReader::new(stdin);
let inputs: Vec<Vec<String>> = reader
.lines()
.take(3)
.map(|x| x.unwrap())
.map(|x| x.split(" ").map(|x| x.to_string()).collect())
.co... | true |
21a5210415c1e7f46ca38e3ba27b4768a2c5fab6 | Rust | bachue/rust-sdk | /upload_token/src/file_type.rs | UTF-8 | 1,324 | 3.125 | 3 | [] | no_license | use duplicate::duplicate;
use smart_default::SmartDefault;
use std::{convert::TryFrom, error::Error, fmt};
/// 文件存储类型
#[derive(Copy, Clone, Debug, Eq, PartialEq, SmartDefault)]
#[non_exhaustive]
pub enum FileType {
/// 标准存储
#[default]
Normal = 0,
/// 低频存储
InfrequentAccess = 1,
/// 归档存储
Gl... | true |
31c72d92edc7186f13d0521e0c8a9aa1ed21574b | Rust | boulanlo/pma | /src/index_par_iterator.rs | UTF-8 | 5,016 | 2.828125 | 3 | [] | no_license | use rayon_adaptive::prelude::*;
use rayon_adaptive::IndexedPower;
use std::ops::Range;
pub struct IndexParIterator<'a> {
pub(crate) element_counts: &'a [usize],
pub(crate) segment_size: usize,
pub(crate) window: Range<usize>,
pub(crate) start_index: usize,
pub(crate) end_index: usize,
pub(crate... | true |
58fc48f28f140d48caed2ccb14c47aee3e7286f4 | Rust | prisma/prisma-engines | /psl/schema-ast/src/ast/identifier.rs | UTF-8 | 565 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use super::{Span, WithSpan};
/// An identifier.
#[derive(Debug, Clone, PartialEq)]
pub struct Identifier {
/// The identifier contents.
pub name: String,
/// The span of the AST node.
pub span: Span,
}
impl WithSpan for Identifier {
fn span(&self) -> Span {
self.span
}
}
impl<T: pest:... | true |
1523b5e55e75bbfd6068f3a68b1625ee1fabb5ca | Rust | udoprog/unicycle | /src/pin_slab.rs | UTF-8 | 7,246 | 4 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! A slab-like, pre-allocated storage where the slab is divided into immovable
//! slots. Each allocated slot doubles the capacity of the slab.
//!
//! Converted from <https://github.com/carllerche/slab>, this slab however
//! contains a growable collection of fixed-size regions called slots.
//! This allows is to sto... | true |
40a37ce31638dfca08a56362e63ebbd861a6e9ff | Rust | shadowmint/rust-isolate | /tests/002_chat_service.rs | UTF-8 | 4,409 | 3.046875 | 3 | [] | no_license | use rust_isolate::Isolate;
use rust_isolate::IsolateChannel;
use rust_isolate::IsolateIdentity;
use rust_isolate::IsolateRegistry;
use rust_isolate::IsolateRegistryRef;
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use std::time::Duration;
#[derive(Debug)]
enum ChatMessage {... | true |
435d03cd6be1c9a8c4b66db3e2b92f7f5e5bf417 | Rust | web-dom/halcyon | /halcyon/src/selector.rs | UTF-8 | 635 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::cmp::Eq;
use std::collections::HashMap;
use std::hash::Hash;
use std::rc::Rc;
use std::thread::LocalKey;
pub fn create_selector<B>(
c: &'static LocalKey<RefCell<HashMap<Rc<B>, i32>>>,
f: fn(Rc<B>) -> i32,
) -> Box<Fn(Rc<B>) -> i32>
where
B: Hash + Eq,
{
Box::new(move |x... | true |
819ea82470de044bc8dc743cbd565ee53f744f1d | Rust | LarsKue/cold_expanding_fluids | /kinetic_theory/src/constants.rs | UTF-8 | 742 | 2.671875 | 3 | [] | no_license | /// Constants for the Simulation are defined here.
pub mod yoshida {
/// 4th-order Yoshida constants, these were pre-calculated with Wolfram-Alpha
/// see Wikipedia: https://en.wikipedia.org/wiki/Leapfrog_integration#Yoshida_algorithms
pub const C14: f64 = 0.675603595979828817023843904485730413460999688108... | true |
8c1b95b6d188a3d016901c0c1f90657db18836cc | Rust | ede0m/nanors | /src/rpc.rs | UTF-8 | 7,217 | 2.578125 | 3 | [] | no_license | // View other options of Public Nano Nodes: https://publicnodes.somenano.com
// https://docs.nano.org/commands/rpc-protocol/#node-rpcs
use crate::block;
use reqwest::Client;
use serde::{
de::{DeserializeOwned, IntoDeserializer},
Deserialize, Deserializer, Serialize,
};
use std::array::IntoIter;
use std::collect... | true |
3d7d4abd618fbe9fdcea59bcb988dcce1bfacba1 | Rust | wujinderead/MyGoProjects | /gotest/leet_rust/tests/leet2202_maximize_the_topmost_element_after_k_moves.rs | UTF-8 | 3,428 | 3.609375 | 4 | [] | no_license | // https://leetcode.com/problems/maximize-the-topmost-element-after-k-moves/
// You are given a 0-indexed integer array nums representing the contents of a pile,
// where nums[0] is the topmost element of the pile.
// In one move, you can perform either of the following:
// If the pile is not empty, remove the topmo... | true |
1cff6ba3012dc57b95fa81022af50e77a6d26f49 | Rust | cloudhead/nakamoto | /chain/src/block/store/io.rs | UTF-8 | 13,878 | 3.09375 | 3 | [
"MIT"
] | permissive | //! Persistent storage backend for blocks.
use std::collections::VecDeque;
use std::fs;
use std::io::{self, Read, Seek, Write};
use std::iter;
use std::mem;
use std::path::Path;
use nakamoto_common::bitcoin::consensus::encode::{Decodable, Encodable};
use nakamoto_common::block::store::{Error, Store};
use nakamoto_com... | true |
3717e8e68803cc27f4b86dbe300305fa195b249f | Rust | werner291/gripper | /src/robot/mod.rs | UTF-8 | 5,366 | 2.71875 | 3 | [] | no_license | //! This mod contains the "standard robot arm": a simulated 4-DoF
//! robotic arm with a three-fingered gripper end-effector.
//!
//! TODO: At some point, we may want to make this more generic, maybe based on URDF?
use std::clone::Clone;
use std::iter::Iterator;
use std::option::Option;
use na::{Vector3};
use np... | true |
5aaab9cd3e2b0944ed3af77f9ca7ce5c864fb794 | Rust | filipdulic/bus-queue | /src/flavors/arc_swap.rs | UTF-8 | 1,700 | 3.046875 | 3 | [] | no_license | #![allow(dead_code)]
use crate::{async_publisher, async_subscriber, publisher, subscriber, SwapSlot};
use arc_swap::ArcSwapOption;
use std::sync::Arc;
pub struct Slot<T> {
shared: ArcSwapOption<T>,
}
impl<T> SwapSlot<T> for Slot<T> {
fn store(&self, item: T) {
self.shared.store(Some(Arc::new(item)))
... | true |
aa4b802e68056665069995d1b1eed47c9918bace | Rust | cleancoindev/steit | /steit/src/types/varint.rs | UTF-8 | 6,533 | 2.859375 | 3 | [] | no_license | use std::io::{self, Read};
use crate::{
impl_state_for_plain,
wire_type::{WireType, WIRE_TYPE_VARINT},
Deserialize, Eof, Merge, Serialize, State,
};
macro_rules! impl_unsigned_varint {
(u64) => (impl_unsigned_varint!(@impl u64, size_64, i64););
($t:ty) => (impl_unsigned_varint!(@impl $t, size_32, ... | true |
7af6b159dc5a3b74c33f8ba6cf7cb6134157e2da | Rust | zen0fpy/vectordb | /src/planners/constant.rs | UTF-8 | 818 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 The VectorDB Authors.
//
// Code is licensed under Apache License, Version 2.0.
use crate::datums::Datum;
#[derive(Debug)]
pub struct ConstantPlanner {
pub val: Datum,
}
impl ConstantPlanner {
pub fn new(t: Datum) -> Self {
ConstantPlanner { val: t }
}
pub fn name(&self) ->... | true |
745a076d405d05e45128691bc81faf6f972770ff | Rust | cole-miller/rust-hashsplit | /src/config.rs | UTF-8 | 2,243 | 2.96875 | 3 | [
"ISC"
] | permissive | #[cfg(feature = "alloc")]
use crate::iter::Spans;
use crate::iter::{Delimited, Distances};
#[allow(unused)]
use crate::util::*;
use crate::{Hasher, Named};
use core::fmt;
#[derive(Clone, Copy, Default)]
pub struct Config<Hash, const THRESHOLD: u32, const MIN_SIZE: usize, const MAX_SIZE: usize> {
pub hasher: Hash,... | true |
14a71436172b55c55ff6d52333e8561c6b8f3719 | Rust | adamchalmers/ipset | /benches/my_benchmark.rs | UTF-8 | 1,274 | 2.609375 | 3 | [] | no_license | use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
use ipnetwork::Ipv4Network;
use ipset::Ipset;
use rand::{thread_rng, Rng};
use std::net::Ipv4Addr;
fn bench_contains(c: &mut Criterion) {
let num_networks = 10;
let mut r = rand::thread_rng();
let mut set = Ipset::default(... | true |
544be931d36c4c5602beee9d36e5e18d1f851ef1 | Rust | msarfati/cargo-rpm | /src/config.rs | UTF-8 | 5,416 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | //! Cargo.toml parser specialized for the `cargo rpm` use case
use failure::Error;
use iq_cli::color::BRIGHT_CYAN;
use std::{
collections::BTreeMap,
fs::{File, OpenOptions},
io::{Read, Write},
path::{Path, PathBuf},
process::exit,
};
use toml;
/// Name of the file containing cargo configuration. Y... | true |
bb1f173b4b9acb3a7470a13d798ed352fd8aee9c | Rust | nightmared/availcheck | /src/task.rs | UTF-8 | 2,446 | 2.9375 | 3 | [] | no_license | use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
pub struct SelectReady<'a, K, Fut> {
inner: &'a mut HashMap<K, Fut>,
}
impl<'a, K, Fut: Unpin> Unpin for SelectReady<'a, K, Fut> {}
pub fn select_ready<'a, F, K>(v: &'a mut HashMap<K, F>) -> SelectReady<'a,... | true |
cf2cd3a5983fa34c1ad342e1360adfa591dcb735 | Rust | vivyir/Voila | /src/parser/conditionals.rs | UTF-8 | 7,009 | 3.21875 | 3 | [
"MIT"
] | permissive | use super::*;
pub trait Conditionals {
fn get_conditionals(&mut self) -> Vec<Conditional>;
fn parse_next_conditional(&mut self) -> super::Conditional;
fn reset_conditionals(&mut self);
}
impl Conditionals for super::Parser {
fn get_conditionals(&mut self) -> Vec<Conditional> {
let mut conditio... | true |
efdccf5844ae8c123ac180f88d3ddb53c7ea9e59 | Rust | Altair-Bueno/fuzzy-disco | /disco-core/src/api/sessions/data.rs | UTF-8 | 500 | 2.609375 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use crate::mongo::user::Session;
#[derive(Serialize, Deserialize, Debug)]
pub struct PublicSessionData {
ip: Option<String>,
date: String,
}
impl PublicSessionData {
pub fn new(ip: Option<String>, date: String) -> Self {
PublicSessionData { ip, date }
}
... | true |
291af193b6225d5dd6de761ec0a2f4e8ec700767 | Rust | selenologist/giu | /src/websocket.rs | UTF-8 | 11,145 | 2.5625 | 3 | [] | no_license | use serde_json;
use ws::{listen, Handler, Factory, Sender, Handshake, Request, Response as WsResponse, Message, CloseCode};
use ws::{Error as WsError, ErrorKind as WsErrorKind, Result as WsResult};
use graph::{PossibleErr as GraphErr, *};
use std::thread;
use std::thread::{JoinHandle};
use std::fmt;
use std::result;
... | true |
ff84bc659bd56f71e36963f24f0e16c9d50286df | Rust | horup/frameworky-rust | /examples/balls/lib.rs | UTF-8 | 1,620 | 2.640625 | 3 | [] | no_license | use std::any::Any;
use components::{Body, Camera};
use components::Transform;
use components::Shape;
use hosts::kiss3d_host::Kiss3DHost;
use rand::random;
use systems::{BodySystem};
use frameworky::*;
use events::{KeyEvent};
use wasm_bindgen::prelude::*;
#[derive(Debug, Default)]
struct ClickSystem
{
spawn:bool
}
... | true |
cc36214c6b8dd724b43624c0b9e3728e43e71955 | Rust | mohaque0/dataclass | /ast/src/lib.rs | UTF-8 | 1,907 | 2.515625 | 3 | [
"MIT"
] | permissive | #[macro_use] extern crate derive_more;
#[macro_use] extern crate getset;
extern crate serde;
mod context;
mod name;
pub use context::Context;
pub use name::Name;
pub use name::QualifiedName;
use serde::Serialize;
use serde::Deserialize;
#[derive(Constructor, Clone, Getters, CopyGetters, Setters, Debug, PartialEq, ... | true |
ad667b3e49e7a555d0a10c72a2d5fc1ca5431365 | Rust | EFanZh/LeetCode | /src/problem_1400_construct_k_palindrome_strings/mathematical.rs | UTF-8 | 899 | 3.015625 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn can_construct(s: String, k: i32) -> bool {
let n = s.len();
let k = k as usize;
let mut counts = [0_u32; 26];
for c ... | true |
86cbdd4173a8015484ecc14838f8b7ee37e137c6 | Rust | chhuang0123/Advent_Of_Code_2020 | /day_04/src/main.rs | UTF-8 | 1,542 | 2.640625 | 3 | [] | no_license | #![allow(dead_code, unused_imports, unused_mut, unused_variables)]
use day_04::{is_valid, is_valid_part_2};
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
// part 1
let filename = &args[0];
let file = File::open(filename).... | true |
d0287ff8423214655b184c8a2d7937aec5aba757 | Rust | ZanAlex/sudoku-solver | /src/main.rs | UTF-8 | 7,530 | 3.28125 | 3 | [] | no_license | use std::fmt;
struct Grid {
cells: [u8; 9 * 9],
lines_state: [u16; 9],
columns_state: [u16; 9],
solved_indices_stack: Vec<usize>,
}
enum PotentialState {
Several(u8),
One(u8),
None,
}
impl Grid {
fn create(values: &[(u8, (usize, usize))]) -> Grid {
let mut cells = [0; 9 * 9]... | true |
53a644b31d0a489bccfe4053221766fb3b3a755f | Rust | sathishvinayk/rust_360 | /types_in_rust/short_introduction_rust_types.rs | UTF-8 | 442 | 2.9375 | 3 | [] | no_license | fn build_vector() -> Vec<u16> {
let mut vector_empty: Vec<u16> = Vec::new();
vector_empty.push(2i16);
vector_empty.push(12i16);
vector_empty
}
fn suppressed_vector() -> Vec<u16> {
let mut vector_empty = Vec::new();
vector_empty.push(1122);
vector_empty.push(72);
vector_empty
}
fn mai... | true |
d83d7ee2ad94ff786920d2a888c7bea1a1c1765f | Rust | chrigu/chip8 | /src/display.rs | UTF-8 | 5,733 | 3.484375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | const WIDTH: usize = 64;
const HEIGHT: usize = 32;
pub const NUM_PIXELS: usize = HEIGHT * WIDTH;
pub struct Display {
memory: [bool; NUM_PIXELS],
fontset: [u8; 80]
}
impl Display {
pub fn new() -> Display {
Display {
memory: [false; NUM_PIXELS],
fontset: [
0... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.