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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6338ac51279c03bb48671eb0d1c6714d608f162f | Rust | yasukotelin/poi | /src/cache.rs | UTF-8 | 1,154 | 2.890625 | 3 | [
"MIT"
] | permissive | use dirs;
use std::fs::File;
use std::io::prelude::*;
use std::{fs, path::PathBuf};
pub struct Cache {
path: PathBuf,
}
impl Cache {
pub fn new() -> Cache {
return Cache {
path: Cache::get_path().unwrap(),
};
}
fn get_path() -> Option<PathBuf> {
match dirs::home_di... | true |
0fb1dc404a6c9b9ebe7eea33affc77890534f154 | Rust | 0xack13/programming-rust | /chapter_06/linked_list/src/lib.rs | UTF-8 | 2,320 | 3.6875 | 4 | [] | no_license | pub struct LinkedList<T> {
head: Option<Node<T>>,
}
struct Node<T> {
val: T,
next: Option<Box<Node<T>>>,
}
pub struct Iter<'a, T: 'a> {
current_node: Option<&'a Node<T>>,
}
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<&'a T> {
if let Some(cur... | true |
772a7b8479e8c501ed2a532e75301bdb452c09a3 | Rust | tuzz/game-engine | /src/resources/keyboard.rs | UTF-8 | 520 | 3.328125 | 3 | [] | no_license | use specs::prelude::*;
#[derive(Default, Debug)]
pub struct Keyboard {
pub pressing: BitSet,
pub just_pressed: BitSet,
pub just_released: BitSet,
}
#[derive(Copy, Clone, Debug)]
pub enum Key {
A, B, C,
}
impl Key {
pub fn lookup(mut code: u32) -> Option<Self> {
if (97..=122).contains(&co... | true |
7afa8c9d4ccde09b04b260d9e00b6b44c7d7a453 | Rust | EmbarkStudios/physx-rs | /physx-sys/pxbind/src/consumer.rs | UTF-8 | 31,405 | 2.5625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::Node;
use serde::Deserialize;
mod record;
use anyhow::Context as _;
pub use record::*;
mod enums;
use clang_ast::Id;
pub use enums::{EnumBinding, FlagsBinding};
pub mod functions;
pub use functions::{FuncBinding, PhysxInvoke};
mod templates;
pub use templates::{Template, TemplateArg};
#[derive(Deserialize... | true |
d457084986f3154ee6c4728f2b90009749c0f3d3 | Rust | lassade/bevy_prefab | /src/registry/component.rs | UTF-8 | 4,735 | 2.78125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use std::any::{type_name, TypeId};
use anyhow::Result;
use bevy::{
ecs::{
//bundle::Bundle,
component::Component,
entity::Entity,
world::{EntityMut, World},
},
reflect::Uuid,
};
use serde::Deserialize;
use thiserror::Error;
use super::Registry;
pub(crate) type ComponentDes... | true |
3d7f94960707284f96da06fb2e0988723138f453 | Rust | robertecurtin/learning-rust | /src/chapter19.rs | UTF-8 | 398 | 2.78125 | 3 | [] | no_license | macro_rules! a_macro {
( $($x:expr), * ) => {
// Match any expression, load into x, allow 0+ matches separated by commas
{
println!("here we go");
$( // Repeat for each comma separated value $x
println!("{}", $x);
)*
}
};
}
pub fn chapter19() {
a_macro!("doggo"); // here we g... | true |
11c334bc9d60c95613ae6e9eb3d679e53424a232 | Rust | CT075/dependent-ghost | /src/proof.rs | UTF-8 | 5,110 | 3.703125 | 4 | [
"MIT"
] | permissive | /// Encode proofs of properties
use std::marker::PhantomData;
/// A value of type `Proof<P>` for some type-encoded property `P` is a proof
/// of that property, which can be manipulated to form other proofs. To ensure
/// that such proofs have no runtime impact, they are implemented as zero-size
/// structs utilizing ... | true |
1c337d574011e788b345247edfb093dd015c7e9c | Rust | 18616378431/myCode | /rust/test4-14/src/main.rs | UTF-8 | 161 | 2.6875 | 3 | [] | no_license | //drop-flag
//使用花括号构造显式作用域主动析构局部变量
fn main() {
let mut v = vec![1, 2, 3];
{
v;
};
v.push(4);
}
| true |
a3f834436f933777cf2931e19819f6a6777b3f54 | Rust | raphaelcohn/security-keys-rust | /workspace/usb-storm/src/interface/audio/control/version_2_entities/unit/feature/Version2FeatureUnitEntity.rs | UTF-8 | 2,887 | 2.53125 | 3 | [
"MIT"
] | permissive | // This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/security-keys-rust/master/COPYRIGHT. No part of security-keys-rust, including this file, may be copied, modified, ... | true |
93a7fe28a568e3d0a9fa1143fdc99a9ff421a84d | Rust | helojo/LoginServer | /src/endpoints/auth/login.rs | UTF-8 | 4,400 | 2.59375 | 3 | [] | no_license | use crate::appdata::AppData;
use actix_web::{post, HttpResponse, web};
use mysql::prelude::Queryable;
use mysql::{Row, Params, params};
use sha2::{Sha512Trunc256, Digest};
use rand::Rng;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct LoginForm {
email_base64: String,
... | true |
c1e2ebb471d1aed582d580a565b5961f0732140e | Rust | siabard/sdl_isometric | /src/ai/astar.rs | UTF-8 | 6,266 | 3.3125 | 3 | [] | no_license | use std::collections::HashSet;
/// A* Node
#[derive(Eq, PartialEq, Debug)]
pub struct Node {
pub f: u32,
pub g: u32,
pub h: u32,
pub x: usize,
pub y: usize,
pub previous: Option<(usize, usize)>,
pub blocked: bool,
}
/// A* Search Algorithm
pub struct AStar {
cols: usize,
rows: usiz... | true |
e470d68aa2cfd4f14ab60cdbc2083145c84ace93 | Rust | rick68/rust-trace | /libcore/convert/trait_Into/into.rs | UTF-8 | 372 | 3.203125 | 3 | [
"MIT"
] | permissive | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::convert::Into;
struct A<T> {
value: T
}
impl Into<T> for A<T> {
fn into(self) -> T {
self.value
}
}
type T = i32;
#[test]
fn into_test1() {
let value: T = 68;
let a: A<T> = A { value: value };
let int... | true |
3408c7daf04dd9e8d235dbf86081a18adca7dd65 | Rust | Pokemod97/rust_master_mind | /src/main.rs | UTF-8 | 5,876 | 3.4375 | 3 | [
"MIT"
] | permissive | use mastermind_core;
use std::collections::HashMap;
use std::env;
use std::io;
use std::process::exit;
fn main() {
for argument in env::args() {
if argument == "bot".to_string() {
play_game();
exit(0);
}
}
loop {
println!("Welcome to mastermind. To guess enter... | true |
5278fe73854aeb5c0b8a4db820f02d56cdbc63d2 | Rust | co0p/rustmas | /src/day02one.rs | UTF-8 | 2,485 | 3.578125 | 4 | [] | no_license | use std::fs::File;
use std::io;
use std::io::BufRead;
use std::path::Path;
use std::string::String;
pub fn solve() {
// read file line by line
let mut counter = 0;
if let Ok(lines) = read_lines("input_day02.txt") {
for line in lines {
if let Ok(entry) = line {
if valid(e... | true |
a08fde04db813d3fe017b5728bb6a172cf260da4 | Rust | CPT-Jack-A-Castle/solana | /sdk/src/sanitized_transaction.rs | UTF-8 | 2,671 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | #![cfg(feature = "full")]
use crate::{
hash::Hash,
sanitize::Sanitize,
transaction::{Result, Transaction, TransactionError},
};
use std::{borrow::Cow, convert::TryFrom, ops::Deref};
/// Sanitized transaction and the hash of its message
#[derive(Debug, Clone)]
pub struct SanitizedTransaction<'a> {
tran... | true |
2d8e0741a829f75713b5818db009db5032ff281d | Rust | MingweiSamuel/spinach | /lib/src/op/splitop.rs | UTF-8 | 5,596 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use std::cell::{Cell, RefCell};
use std::task::{Context, Poll, Waker};
use std::rc::{Rc, Weak};
use crate::hide::{Hide, Delta, Value};
use super::*;
pub fn fixed_split<O: Op, const N: usize>(op: O) -> [SplitOp<O>; N] {
let splitter = Splitter::new(op);
[(); N].map(|_| splitter.internal_add_split_reveal())
}... | true |
f6377febb39eb901d2389c420fd2d1b6383b2852 | Rust | ferocious-ferret/throatql | /src/auth.rs | UTF-8 | 4,537 | 2.890625 | 3 | [] | no_license | use futures::executor::block_on;
use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct Claims {
sub: String,
exp: usize,
preferred_username: String,
}
#[derive(Debug, PartialEq)]
pu... | true |
1c2715572328b98a093157cf1d03119fa1f48bd4 | Rust | fewensa/rtdlib | /src/types/reset_password_result.rs | UTF-8 | 10,126 | 2.75 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
use std::fmt::Debug;
use serde::de::{Deserialize, Deserializer};
/// TRAIT | Represents result of 2-step verification password reset
pub trait TDResetPasswordResult: Debug + RObject {}
/// Represents result of 2-step verification password reset
#[deriv... | true |
f6a89965994af0832d60a470348d82bc527ab882 | Rust | lunchboxav/rust-and-js | /rust-and-node-randomizer/src/lib.rs | UTF-8 | 692 | 2.75 | 3 | [] | no_license | extern crate libc;
use std::ffi::CString;
use std::ffi::CStr;
use libc::c_char;
#[no_mangle]
pub extern fn randomize(pw: *const c_char, num: u8) -> *const c_char {
// vector to store the chars
let mut char_vec = Vec::new();
// transferring C String
let c_str = unsafe {
CStr::from_ptr(pw)
... | true |
426e98eb13e0e63169052aec484ba1f991f48310 | Rust | jeremyandrews/rs-natural | /src/tf_idf.rs | UTF-8 | 2,435 | 3.234375 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use std::collections::HashMap;
use stem;
use tokenize::tokenize;
#[cfg(feature = "serde_support")]
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))]
pub struct TfIdf {
//token counts for inverse document frequency
doc_freqs: HashMap<S... | true |
a0ce443a9fa8a5fed346e3aea9f9b0919ce4b211 | Rust | sajattack/bitbang-hal | /src/i2c.rs | UTF-8 | 7,717 | 2.609375 | 3 | [
"MIT"
] | permissive | /*!
# Synchronous implementation of embedded-hal I2C traits based on GPIO bitbang
This implementation consumes the following hardware resources:
- A periodic timer to mark clock cycles
- Two GPIO pins for SDA and SCL lines.
Note that the current implementation does not support I2C clock stretching.
## Ha... | true |
e6fec2d2e8eaac48417d4e4f1928f7042aef895d | Rust | marco-c/gecko-dev-wordified | /third_party/rust/futures-util/src/stream/poll_fn.rs | UTF-8 | 1,522 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | /
/
!
Definition
of
the
PollFn
combinator
use
super
:
:
assert_stream
;
use
core
:
:
fmt
;
use
core
:
:
pin
:
:
Pin
;
use
futures_core
:
:
stream
:
:
Stream
;
use
futures_core
:
:
task
:
:
{
Context
Poll
}
;
/
/
/
Stream
for
the
[
poll_fn
]
function
.
#
[
must_use
=
"
streams
do
nothing
unless
polled
"
]
pub
struct
Pol... | true |
e1fc40398094b9d0b38382414765bf5892495b3e | Rust | kira-bruneau/elemeld | /src/hub.rs | UTF-8 | 7,338 | 2.625 | 3 | [] | no_license | use io::*;
use cluster::Cluster;
use config_server::ConfigServer;
use mio::*;
use ws::{WebSocket, Sender as WsSender};
use serde_json;
use std::io;
use std::net::SocketAddr;
use std::thread;
const HOST_EVENT: Token = Token(0);
const NET_EVENT: Token = Token(1);
pub struct Hub<H, N> where
H: HostInterface + Even... | true |
d9f93938a55b6fd3b106578bf6c0614b4a75a15a | Rust | heyLu/lp | /rust/list.rs | UTF-8 | 571 | 3.203125 | 3 | [] | no_license | #[deriving(Show)]
pub enum List<A> {
Nil,
Cons(A, Box<List<A>>)
}
pub fn cons<A>(x: A, xs: Box<List<A>>) -> Box<List<A>> {
match *xs {
Nil => box Cons(x, box Nil),
l => box Cons(x, box l)
}
}
pub fn first<A>(xs: List<A>) -> Option<A> {
match xs {
Nil => None,
Cons(x... | true |
fecd5ee12de30b7a1ae89a07c693e5f33450a246 | Rust | dnorman/unbase | /crates/unbase/examples/ping.rs | UTF-8 | 1,583 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | extern crate unbase;
use futures::StreamExt;
use std::time::Duration;
use timer::Delay;
use unbase::{
network::transport::TransportUDP,
Entity,
Network,
Slab,
};
#[async_std::main]
async fn main() {
let net = Network::create_new_system();
let udp = TransportUDP::new("127.0.0.1:12001".to_string(... | true |
69f1b13da10468230af1d0d2acaad1e557c53109 | Rust | Hugal31/los2d | /src/diamond.rs | UTF-8 | 10,439 | 2.6875 | 3 | [] | no_license | use super::{Coord, LosAlgorithm, Map, MapProvider};
/// Implementation of the Diamond LOS algorithm.
///
/// See <> for more information,
/// and https://github.com/libtcod/libtcod/blob/master/src/libtcod/fov_diamond_raycasting.c#L149
/// for an example implementation
#[derive(Clone, Debug)]
pub struct DiamondLos {
... | true |
d9bf657f4134fbf085e419c02e611f93c96fad20 | Rust | achntrl/logmonitoring | /src/consumer/ranker.rs | UTF-8 | 5,047 | 3.015625 | 3 | [] | no_license | use std::collections::HashMap;
use consumer::Consumer;
use parser::HttpLog;
#[derive(Debug)]
pub struct Ranker {
top_sections: HashMap<String, u32>,
top_hosts: HashMap<String, u32>,
max_ranking: usize,
}
impl Ranker {
pub fn new() -> Ranker {
let top_sections: HashMap<String, u32> = HashMap::... | true |
e6bcab311b26e1ee15a9360782b1a487cc62d171 | Rust | cv1002/gluesql | /src/translate/function.rs | UTF-8 | 8,419 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use {
super::{
ast_literal::translate_trim_where_field, expr::translate_expr, translate_object_name,
TranslateError,
},
crate::{
ast::{Aggregate, Expr, Function, ObjectName, TrimWhereField},
result::Result,
},
sqlparser::ast::{
Expr as SqlExpr, Function as Sql... | true |
08c0c8974f165c09ff83d787fb0ac76851b74d11 | Rust | Parabellum1905y/doublelinkedlist | /src/linked_list.rs | UTF-8 | 674 | 3.390625 | 3 | [] | no_license | use element::Element;
#[derive(Clone)]
pub struct LinkedList {
head: Option<Box<Element>>,
tail: Option<Box<Element>>,
size: u32
}
impl LinkedList {
pub fn new() -> LinkedList {
LinkedList {
head: None,
tail: None,
size: 0
}
}
pub fn get_hea... | true |
145b6839a5b5042874d6d9f48bec2f2e46659941 | Rust | jimmycuadra/retry | /src/opresult.rs | UTF-8 | 3,191 | 4 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Provides a ternary result for operations.
//!
//! # Examples
//!
//! ```rust
//! # use retry::retry;
//! # use retry::delay::Fixed;
//! use retry::OperationResult;
//! let mut collection = vec![1, 2].into_iter();
//! let value = retry(Fixed::from_millis(1), || {
//! match collection.next() {
//! Some(n)... | true |
865b0cb7b8261097e16483556760fe3a01e84183 | Rust | henrywallace/blush | /src/eval.rs | UTF-8 | 1,460 | 3.015625 | 3 | [] | no_license | use crate::index::Index;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
#[derive(Debug)]
pub struct Eval {
queries: Vec<String>,
}
// Goals of Eval:
// - Load query keys from file.
// ... | true |
14f8277d13df52950ea36e4b333f61d4d53ec55e | Rust | Wizdave97/rust-handbook | /blog/src/main.rs | UTF-8 | 436 | 2.75 | 3 | [] | no_license | use blog::blog;
fn main() {
let mut post = blog::Post::new();
post.add_text("It's been an awesome year");
let post = post.request_review();
let post = post.request_review();
let post = post.reject();
let post = post.request_review();
let post = post.request_review();
let post = po... | true |
2d9c8339e59a8a36596868462fbfcfdbab69168c | Rust | nuhtan/lifestyle | /src/core/state_data/state.rs | UTF-8 | 4,528 | 2.890625 | 3 | [] | no_license | use std::{
fs::{self, File},
io::{BufRead, BufReader, LineWriter, Write},
net::SocketAddr,
path::{Path, PathBuf},
sync::{Arc, Mutex},
};
use serde::Serialize;
use super::{super::StatefulList, Basic, calories::Calories, progress::Progress, shopping_item::ShoppingItem, valorant_game::ValorantGame};
... | true |
75132a831798ed8b4dc4b4d5267e93840b7f61aa | Rust | tglanz/chip8 | /arch/src/memory.rs | UTF-8 | 1,530 | 3.390625 | 3 | [] | no_license | use std::iter::Iterator;
use {Byte};
pub const FONT_OFFSET: usize = 0;
pub const PROGRAM_OFFSET: usize = 0x200;
const MEMORY_SIZE: usize = 4096;
const FONT: [Byte; 5 * 16] = [
// 0
0xF0, 0x90, 0x90, 0x90, 0xF0,
// 1
0x20, 0x60, 0x20, 0x20, 0x70,
// 2
0xF0, 0x10, 0xF0, 0x80, 0xF0,
// 3 ... | true |
53806e2f578ee6d13e3a65d47052811918c32b4a | Rust | ambv/edgedb-cli | /src/server/install/operation.rs | UTF-8 | 5,834 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::BTreeMap;
use std::process::{Command as StdCommand, Stdio, ExitStatus};
use std::ffi::OsString;
use std::fs;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use anyhow::Context as ContextExt;
#[derive(Debug)]
pub struct Command {
cmd: PathBuf,
environ: BTreeMap<OsString, OsS... | true |
5f2f35297b9f1bce3ae5e513f2077cbca4b6f1c1 | Rust | rust-lang/cargo | /src/cargo/core/resolver/dep_cache.rs | UTF-8 | 22,848 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"Apache-2.0",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"OpenSSL",
"curl",
"LGPL-2.1-only",
"BSD-2-Clause",
"LicenseRef-scancode-ssleay-windows",
"Unlicense"
] | permissive | //! There are 2 sources of facts for the resolver:
//!
//! - The `Registry` tells us for a `Dependency` what versions are available to fulfil it.
//! - The `Summary` tells us for a version (and features) what dependencies need to be fulfilled for it to be activated.
//!
//! These constitute immutable facts, the soled g... | true |
a6b451297d8454696f0a473bb6274cb7be058f2f | Rust | nice-game/assimp-rs | /assimp/src/scene/mesh.rs | UTF-8 | 1,037 | 2.515625 | 3 | [] | no_license | use assimp_sys::*;
use std::{iter, slice};
define_type! {
struct Mesh(&aiMesh)
}
impl<'a> Mesh<'a> {
pub fn vertices(&self) -> &[[f32; 3]] {
unsafe { slice::from_raw_parts(self.mVertices as _, self.mNumVertices as _) }
}
pub fn normals(&self) -> &[[f32; 3]] {
unsafe { slice::from_raw_parts(self.mNormals as _,... | true |
9d0fade5a7b27e1b8635bfdfb9212439d606fb7b | Rust | simensgreen/bevy | /crates/bevy_ecs/src/query/mod.rs | UTF-8 | 5,932 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | mod access;
mod fetch;
mod filter;
mod iter;
mod state;
pub use access::*;
pub use fetch::*;
pub use filter::*;
pub use iter::*;
pub use state::*;
#[cfg(test)]
mod tests {
use crate::{self as bevy_ecs, component::Component, world::World};
#[derive(Component, Debug, Eq, PartialEq)]
struct A(usize);
#[... | true |
9c5fc5a2d3877250931e221b03d1067ef3d7a8de | Rust | SatioO/rust-practices | /src/string.rs | UTF-8 | 194 | 3.21875 | 3 | [] | no_license | fn main() {
let hello = String::from("Hello world !");
let hello1 = "Hello world !";
print_str(&hello);
print_str(hello1);
}
fn print_str(val: &str) {
println!("{}", val)
}
| true |
e696796fc93028d8eae6abb46e1f0c91b376c7cc | Rust | aptend/leetcode-rua | /Rust/src/n0074_search_a_2d_matrix.rs | UTF-8 | 604 | 3.328125 | 3 | [] | no_license | pub fn search_matrix(matrix: Vec<Vec<i32>>, target: i32) -> bool {
let flat: Vec<i32> = matrix.into_iter().flatten().collect();
flat.binary_search(&target).is_ok()
}
#[test]
fn test_74() {
let m = vec![vec![1, 3, 5, 7], vec![10, 11, 16, 20], vec![23, 30, 34, 50]];
assert_eq!(false, search_matrix(Vec::<... | true |
ee7e365c8a99f209c20bfe7062c2c1f5c11f5e95 | Rust | NestedWorld/NestedWorld-Server-RealTime | /server/src/net/msg/combat/data/monster.rs | UTF-8 | 1,096 | 2.65625 | 3 | [] | no_license | use net::msg::{MessagePart};
use net::msg::error::Result;
use net::msg::utils::fields;
use net::msg::utils::rmp::ValueExt;
use rmp::Value;
#[derive(Debug, Clone, PartialEq)]
pub struct Monster {
pub id: u32,
pub name: String,
pub monster_id: u32,
pub user_monster_id: Option<u32>,
pub hp: u16,
p... | true |
184d937e47e06c4b71e29bd9253302492177b442 | Rust | jbaldwin/adventofcode | /2021/day08/p1/src/main.rs | UTF-8 | 800 | 3.125 | 3 | [
"MIT"
] | permissive | fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
println!("{} <input_file>", args[0]);
std::process::exit(-1);
}
let lines: Vec<String> = std::fs::read_to_string(&args[1])
.unwrap()
.split('\n')
.into_iter()
.map(|s| s.t... | true |
eb387e9f2f8e6dff8edda1b7bec85e2658bdbad1 | Rust | mattias-p/fillout | /src/template.rs | UTF-8 | 9,148 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | pub mod token {
use std::collections::HashMap;
use std::fmt;
#[derive(Debug, Eq, PartialEq)]
pub enum Token<'a> {
Lit(&'a str),
Var(&'a str),
}
impl<'a> Token<'a> {
pub fn as_var(&self) -> Option<&'a str> {
if let Token::Var(s) = self {
Some(... | true |
0aab51032dbffb9f6dfccc19da6ec9f3b122a0cb | Rust | csark/learn-rust | /ch8-strings/src/main.rs | UTF-8 | 1,293 | 4.09375 | 4 | [] | no_license | fn main() {
let mut s = String::new(); // create and empty string
// Initialize string with data
let data = "initial contents";
let s = data.to_string();
// or
let s = "initial contents".to_string();
// or
let s = String::from("initial contents");
// Concatenation
let mut s =... | true |
b716906f3abbab981e2831046131364c2aafcbe8 | Rust | attentec/highlevel-rust | /src/net.rs | UTF-8 | 1,428 | 2.84375 | 3 | [] | no_license | // Module uses reqwest as the underlying http client
extern crate reqwest;
// We use serde_json to work with Json
extern crate serde_json;
use ::std;
// Using error_chain for this module's errors
// Do not generate any "Result"-type, declare that our
// error should be converitible from reqwest network errors,
// i... | true |
815f0f1014fe710dad272c87c5e2845a0fdc31ba | Rust | Thomasdezeeuw/human-size-rs | /src/multiples.rs | UTF-8 | 6,694 | 3.640625 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Module containing all multiples.
//!
//! All types defined here implement [`Multiple`]. Because all types defined
//! here, expect for `Any`, don't have any fields they are always zero sized.
//! Meaning that for example `SpecificSize<Byte>` has the same size as `f64`
//! (the type used as underlying value).
//!
//... | true |
64ce8c0a931f5151e6a3b59b5d394785893aba01 | Rust | saks/exercism-exercises | /rust/beer-song/src/lib.rs | UTF-8 | 1,093 | 3.40625 | 3 | [
"MIT"
] | permissive | const ENDING: &str = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n";
pub fn verse(n: i32) -> String {
match n {
0 => String::from(ENDING),
_ => sign_one(n),
}
}
fn bottles(n: i32) -> String {
let number ... | true |
4ab5b3ba84d8c4bf7df8c86360b26e839d2cf06a | Rust | suzu6/trial-code | /rust/atcoder/abc049/src/bin/c.rs | UTF-8 | 710 | 3.109375 | 3 | [] | no_license | use std::str;
fn main() {
proconio::input! {
s: String
}
// 逆から探す
let s: Vec<char> = s.chars().rev().collect();
let patterns: Vec<Vec<char>> = [
"dream",
"dreamer",
"erase",
"eraser"]
.iter()
.map(|x| x.chars().rev().collect())
.colle... | true |
303f9fdf1ca3a9352188bad07513a1f42b508c38 | Rust | iCodeIN/crcxx | /src/tests.rs | UTF-8 | 3,569 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use std::prelude::v1::*;
use rand::{thread_rng, Rng};
use super::*;
const ITERATIONS: usize = 10_000;
const MIN_DATA_SIZE: usize = 1;
const MAX_DATA_SIZE: usize = 4096;
fn gen_rand_data(min_data_size: usize, max_data_size: usize) -> Box<[u8]> {
let mut rng = thread_rng();
let data_size = rng.gen_range(min_d... | true |
e7f5322657ddd91dc83f69786937b267f94b40fb | Rust | mattnenterprise/rust-box2d | /src/collision/collide_circle.rs | UTF-8 | 4,492 | 2.828125 | 3 | [
"MIT"
] | permissive | use super::manifold::{Manifold, ManifoldType};
use super::shapes::circle_shape::CircleShape;
use super::shapes::polygon_shape::PolygonShape;
use super::contact_id::ContactID;
use super::super::common::Transform;
use super::super::common::Vec2;
use super::super::common::math::{mul_transform_vec2, mul_transform_vec2_inve... | true |
29ebfc3a917f2eecb6c2d4cd6f865e3292f78df5 | Rust | grauwoelfchen/daccord | /src/sprinkle/tests/integration_test.rs | UTF-8 | 708 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
mod integration_test {
use std::io::Write;
use std::process::{Command, Stdio};
#[test]
fn test_run_with_piped_stdin() {
let mut sprinkle = Command::new("./target/debug/sprinkle")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("sprinkle command failed to... | true |
a65bb00276c28121f14e5e4a666e1e170f2ef211 | Rust | gin66/uservpn-socks5 | /src/database.rs | UTF-8 | 10,246 | 3.0625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // This module captures all relevant information from all areas.
//
use std::rc::Rc;
use std::str::FromStr;
use std::option::Option;
use std::net::{SocketAddr};
use ini;
use country::{country_hash,MAX_COUNTRY_HASH};
#[derive(Debug)]
pub struct Node {
id: u8,
name: String,
probe: Option<String>,
country... | true |
36dd61e963ef0324b85a41071391ccfc6231d26d | Rust | jgraef/rustorio | /rustorio-circuits/src/compiler/mod.rs | UTF-8 | 22,468 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::{
str::FromStr,
collections::HashMap,
};
use thiserror::Error;
use crate::{
parser::ast,
ir,
};
use rustorio_core::blueprint::types::{SignalType, SignalIDParseError};
#[derive(Debug, Error)]
pub enum CompilerError {
#[error("TODO")]
Todo,
#[error("Unknown wire: {0}")]
Unkno... | true |
e956f1a2223419b43a7058da34a2b3b304d0e188 | Rust | mathiasmagnusson/kattis | /po_kuber.rs | UTF-8 | 207 | 2.640625 | 3 | [] | no_license | use std::io::stdin;
fn main() {
println!("{}", (0..={
let mut line = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
}).map(|n: usize| n.pow(3)).sum::<usize>());
} | true |
e49f541acb9f543750f2445073f40abd509b540a | Rust | arthurDz/algorithm-studies | /rust/remove_palindromic_subsequences.rs | UTF-8 | 536 | 2.859375 | 3 | [] | no_license | impl Solution {
pub fn remove_palindrome_sub(s: String) -> i32 {
fn is_palindrome(st: &String) -> bool {
let c: Vec<char> = st.chars().collect();
let c_len = c.len();
for i in 0..c_len/2 {
if c[i] != c[c_len - i - 1] {
... | true |
d1c9abb92fdd2085e28f849fa35a40402a4fdfb5 | Rust | brianduff/learnrust | /match_operator/src/main.rs | UTF-8 | 977 | 4.0625 | 4 | [] | no_license | #[derive(Debug)]
enum UsState {
Alabama,
Alaska,
}
enum Coin {
Penny,
Nickel,
Dime,
Quarter(UsState),
}
fn main() {
test_match_with_enum();
test_match_with_option();
}
fn test_match_with_enum() {
println!("The value of a dime is {}c", value(Coin::Dime));
value(Coin::Quarter(Us... | true |
e7c386c644f0bfd02a286baa0ff178cf6a44e50c | Rust | illicitonion/code-graffiti | /src/models.rs | UTF-8 | 436 | 2.90625 | 3 | [] | no_license | use std::fmt;
#[derive(Clone)]
pub struct LineInRepo {
pub repo_user: String,
pub repo_name: String,
pub sha: String,
pub path: String,
pub line: usize,
}
pub struct GithubRepository<'a> {
pub user: &'a str,
pub name: &'a str,
}
impl<'a> fmt::Display for GithubRepository<'a> {
fn fmt(... | true |
38a490aa0b772de38381ecaa600aec38db57f3a4 | Rust | parallaxisjones/spider | /src/page.rs | UTF-8 | 3,918 | 3.5625 | 4 | [
"MIT"
] | permissive | use reqwest;
use scraper::{Html, Selector};
use url::Url;
/// Represent a page visited. This page contains HTML scraped with [scraper](https://crates.io/crates/scraper).
///
/// **TODO**: store some usefull informations like code status, response time, headers, etc..
#[derive(Debug, Clone)]
pub struct Page {
/// U... | true |
22aefb6a3caab12e2113714e157e52034f41a212 | Rust | gitter-badger/rust-av | /data/src/pixel.rs | UTF-8 | 24,894 | 2.9375 | 3 | [
"MIT"
] | permissive | //!
//! Expose all necessary data structures to represent pixels.
//!
//! Re-exports num_traits::FromPrimitive and num_traits::cast::ToPrimitive in order to make easy to cast a parsed value into correct
//! enum structures
//!
//!
use num_derive::{FromPrimitive, ToPrimitive};
pub use num_traits::cast::ToPrimitive;
p... | true |
549331cdc5326b3553b43978813cfa83d97662b9 | Rust | wyattades/rogue-rs | /src/colors.rs | UTF-8 | 13,765 | 2.96875 | 3 | [] | no_license | #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
// #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl Color {
pub const fn new(r: u8, g: u8, b: u8) -> Color {
Color { r, g, b }
}
pub fn to_hex_str(&self) -> String {
... | true |
28f0895080c1fbbb729a41dda73ba04bdd646d30 | Rust | mfonism/__rust-by-example__ | /02-custom-types/aa-exercise-square.rs | UTF-8 | 689 | 3.546875 | 4 | [] | no_license | #[derive(Debug)]
struct Point {
x: f32,
y: f32,
}
#[derive(Debug)]
struct Rectangle {
top_left: Point,
bottom_right: Point,
}
fn make_square(bottom_left: Point, size: f32) -> Rectangle {
let Point {
x: bottom_left_x,
y: bottom_left_y,
} = bottom_left;
Rectangle {
to... | true |
3cadf6823b4fc1cee4fca6eac4cffa1b0132d49b | Rust | venkypolls/Rust-language-learnings | /src/arrays.rs | UTF-8 | 419 | 3.765625 | 4 | [] | no_license | use std::mem;
pub fn run(){
let numbers: [i32;5] = [1,2,3,4,5];
println!("the numbers are {:?}",numbers);
println!("the first number is {}",numbers[0]);
println!("the length of the array is {}", numbers.len());
println!("the array occupies bytes : {}", mem::size_of_val(&numbers));
//slicing t... | true |
b07f85d4848ac44e06022df9fe5efd429cc015fe | Rust | installgentoo/rust-nn | /src/test_ai/main.rs | UTF-8 | 1,940 | 2.640625 | 3 | [] | no_license | #![warn(clippy::all)]
#![allow(clippy::range_plus_one)]
mod network;
use rand_xorshift::XorShiftRng;
use rand::{Rng, SeedableRng};
use std::cell::RefCell;
use network::NeuralNet;
fn main() {
let rng = RefCell::new(XorShiftRng::from_rng(rand::thread_rng()).unwrap());
let get_random = || rng.borrow_mut().gen_range(0... | true |
c9c288195499f7bdcd3bb0fea650674deb9777eb | Rust | CarlosBquate/libdotbc | /src/rs/cmd/ls_files.rs | UTF-8 | 824 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
const USAGE: &'static str = "
dotbc ls-files
Usage:
dotbc ls-files -f <dotbc>
Options:
-f <dotbc> Path to .bc file
-h, --help Show this message
";
use dotbc::DotBC;
use super::Error;
use docopt::Docopt;
use std::path::Path;
#[derive(Debug, RustcDecodable)]
struct Args {
flag_f: String,
}
... | true |
a9b6cb77b2d8448b85510ecbc0cad1c9726520dd | Rust | gcfbn/learning_rust | /graphs/runner/src/cli.rs | UTF-8 | 1,921 | 3.046875 | 3 | [] | no_license | use clap::{AppSettings, Clap};
use crate::errors::RunnerError;
use crate::subcommands::*;
const APP_NAME: &str = "runner";
/// Arguments read from console by Clap
#[derive(Debug, Clap)]
#[clap(
name = APP_NAME,
version = "1.0",
about = "Algorithms & Data structures task from graph theory",
author = "Bartek M. <bmeka... | true |
38ac72e03a5fcb18be9c3e6a0ea6bffc5f2dc564 | Rust | pimox/proxmox | /proxmox/src/sys/linux/tty.rs | UTF-8 | 5,704 | 2.796875 | 3 | [] | no_license | use std::io::{self, Read, Write};
use std::mem::MaybeUninit;
use std::os::unix::io::AsRawFd;
use anyhow::*;
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
use crate::sys::error::SysError;
use crate::tools::fd::Fd;
use crate::{c_try, try_block};
/// Get the current size of the terminal (for stdout).
/// # Safety
//... | true |
425e1e2647ca8014f6b0431365f8c03ec1fd0553 | Rust | camerondavison/ift | /src/bin/ift.rs | UTF-8 | 1,667 | 2.90625 | 3 | [
"MIT"
] | permissive | use clap::{crate_authors, crate_version, App, AppSettings, SubCommand};
use failure::{bail, Error};
use ift::{eval, rfc::WithRfc6890};
fn main() {
if let Err(ref e) = run() {
eprintln!("error: {}", e);
::std::process::exit(1);
}
}
fn run() -> Result<(), Error> {
let matches = App::new("ift... | true |
73c0b8e421ca15f3f2210c64f4f023961b56ba34 | Rust | simonsan/rd | /src/gdb_expression.rs | UTF-8 | 13,219 | 2.5625 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | use crate::{remote_ptr::RemotePtr, session::task::Task};
/// Extracted from
/// <https://sourceware.org/gdb/current/onlinedocs/gdb/Bytecode-Descriptions.html>
#[allow(non_camel_case_types)]
#[repr(u8)]
enum Opcode {
OP_float = 0x01,
OP_add = 0x02,
OP_sub = 0x03,
OP_mul = 0x04,
OP_div_signed = 0x05,... | true |
534d431ba6b5cf465f0fefdb77b0aee12933e3bc | Rust | shiki-tak/ddd-at-rust | /chapter08_sample_application/src/domain/value_object/name.rs | UTF-8 | 1,022 | 3.0625 | 3 | [] | no_license | use std::str::FromStr;
use anyhow::Result;
use common::MyError;
use derive_more::Display;
use serde::{de, Serialize, Serializer};
#[derive(Clone, Debug, PartialEq, Eq, Display)]
pub struct Name(String);
impl Name {
pub fn new(s: &str) -> Result<Self> {
if s.chars().count() < 3 || s.chars().count() > 20 {... | true |
c8527e4be3ee31d7a90d86735d1902694712eee2 | Rust | decentninja/Avanza-stock-bond-ratio | /src/main.rs | UTF-8 | 2,922 | 3.125 | 3 | [] | no_license | /// The main commandline interface for the analysis.
use std::env;
use std::io::{self, Write};
extern crate rpassword;
extern crate serde_json;
mod analysis;
mod avanza;
fn main() -> Result<(), serde_json::Value> {
let args: Vec<String> = env::args().collect();
let auth = if args[1] == "auth" {
if arg... | true |
9142180d412d2f0971101b5bbee5407575f1b028 | Rust | Ryan1729/bartog | /libs/platform_types/src/platform_types.rs | UTF-8 | 3,352 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | #[macro_use]
extern crate bitflags;
pub const GFX_WIDTH: usize = 128;
pub const GFX_HEIGHT: usize = 128;
pub const GFX_LENGTH: usize = GFX_WIDTH * GFX_HEIGHT;
pub const FONT_WIDTH: usize = 128;
pub const FONT_HEIGHT: usize = 128;
pub const FONT_LENGTH: usize = FONT_WIDTH * FONT_HEIGHT;
pub type PaletteIndex = u8;
p... | true |
e7abd1d690b2338eda098f2e9cad600dc5d909f0 | Rust | hudson-ayers/tock | /boards/components/src/bmp280.rs | UTF-8 | 3,321 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Component for the BMP280 Temperature and Pressure Sensor.
//!
//! Based off the SHT3x code.
//!
//! I2C Interface
//!
//! Usage
//! -----
//!
//! With the default i2c address
//! ```rust
//! let bmp280 = components::bmp280::Bmp280Component::new(sensors_i2c_bus, mux_alarm).finalize(
//! components::bmp280_co... | true |
558147057ee7b39113c756015c8a106cba2cac0d | Rust | Noah2610/deathframe | /deathframe_physics/src/query/exp/query_value_side.rs | UTF-8 | 2,449 | 3.125 | 3 | [
"MIT"
] | permissive | use super::{CollisionInnerSideX, CollisionInnerSideY, CollisionSide};
use std::cmp::PartialEq;
use std::hash::Hash;
#[derive(PartialEq, Eq, Clone, Hash, Deserialize)]
pub enum QueryValueSide {
Left,
Right,
Top,
Bottom,
Inner,
InnerSide {
x: Option<QueryValueInnerSideX>,
y: Optio... | true |
8a421cd383faf2378c5b1328d489a514af7e943b | Rust | steve3p0/cs510r | /hw3/wordy/tests/wordy_steve.rs | UTF-8 | 1,201 | 3.265625 | 3 | [] | no_license | extern crate wordy;
use wordy::*;
#[test]
fn simple_answer_plus1() {
let command = "What is 5 plus 13?";
assert_eq!(Ok(18), WordProblem::new(command).answer())
}
#[test]
fn simple_answer_plus2() {
let command = "What is 5 plus 13 plus -6?";
assert_eq!(Ok(12), WordProblem::new(command).answer())
}
#[... | true |
b14e5bd67634c40b6152ca1a0e2fa85142e5d9f5 | Rust | markschl/seqtool | /src/cmd/count.rs | UTF-8 | 6,637 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::fmt::Debug;
use std::fmt::Write;
use std::mem;
use csv;
use cfg;
use error::CliResult;
use fxhash::FxHashMap;
use opt;
use var::varstring;
static USAGE: &'static str = concat!(
"
This command counts the number of sequences and prints the number to STDOUT. Advanced
grouping of sequences is possible by su... | true |
f2c0fa2a3ebff2150b510c2cd1767ac7664e7bc2 | Rust | iCodeIN/kafka-protocol | /src/parser/record.rs | UTF-8 | 2,374 | 2.921875 | 3 | [] | no_license | use super::*;
pub fn record<'i, I>() -> impl Parser<I, Output = Record<'i>> + 'i
where
I: RangeStream<Token = u8, Range = &'i [u8]> + 'i,
I::Error: ParseError<I::Token, I::Range, I::Position>,
{
(
varint().expected("length"),
be_i8().expected("attributes"),
varint().expected("timesta... | true |
90c54f2f2f9b5d2b5d95a9079a55d0db3fc1c85c | Rust | rust-lang/miri | /tests/fail/stacked_borrows/pass_invalid_mut.rs | UTF-8 | 337 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Make sure that we cannot pass by argument a `&mut` that got already invalidated.
fn foo(_: &mut i32) {}
fn main() {
let x = &mut 42;
let xraw = x as *mut _;
let xref = unsafe { &mut *xraw };
let _val = unsafe { *xraw }; // invalidate xref
foo(xref); //~ ERROR: /retag .* tag does not exist in the... | true |
8930d55b24588dde5250ccc9258b8f8e67272404 | Rust | jimrain/sva_cmcd | /src/main.rs | UTF-8 | 3,956 | 3.109375 | 3 | [] | no_license | //! Default Compute@Edge template program.
use fastly::http::Method;
use fastly::{Error, Request, Response};
use std::collections::HashMap;
use uuid::Uuid;
/// The name of a backend server associated with this service.
///
/// This should be changed to match the name of your own backend. See the the `Hosts` section o... | true |
fb9c4d78c2d2f18ab4ca91f02e0cc9b3b679588b | Rust | glurbi/adventofcode2017 | /src/bin/day22.rs | UTF-8 | 5,495 | 3.015625 | 3 | [] | no_license | use std::fmt;
use std::str;
use std::ops::{Index, IndexMut};
const INPUT: &'static str = include_str!("../../input/Day22.txt");
#[derive(Debug)]
enum Dir { N, S, E, W }
use Dir::{ N, S, E, W };
struct Cluster {
width: i64,
height: i64,
v: Vec<u8>,
vx: i64,
vy: i64,
dir: Dir,
infections: u... | true |
fdb9b53411334c20dc0eac9a4ab009b0bc1f5a41 | Rust | niranjana687/30-days-of-rust | /single-number/src/main.rs | UTF-8 | 157 | 2.671875 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
}
use std::collections::HashMap;
fn single_number(nums: Vec<i32>) -> i32 {
let hash = HashMap::new();
} | true |
0259cdeae92db3f723f4f33042827ec09d620852 | Rust | PoeBlu/lily | /src/audio.rs | UTF-8 | 5,361 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use std::time::{SystemTime, UNIX_EPOCH};
use hound;
use rodio::source::Source;
use cpal::traits::HostTrait;
use std::time::Duration;
pub struct PlayDevice {
device: rodio::Device
}
impl PlayDevice {
pub fn new() -> PlayDevice {
let device = rodio::default_output_device().unwrap();
Pl... | true |
3f0de20888f7bfbc15b3a7034e4dcf818acb5ed2 | Rust | Funkschy/kantan | /src/resolve/error.rs | UTF-8 | 5,418 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::fmt;
use super::types::Type;
use crate::{err_to_string, find_line_index, format_error, parse::token::Token, Source, Span};
#[derive(Debug, Eq, PartialEq)]
pub struct ResolveError<'src> {
pub source: &'src Source,
pub error: ResolveErrorType<'src>,
pub err_span: Span,
pub expr_span: Span,
}
i... | true |
5991a346758549bf802449b39024db94616ae0ec | Rust | Farzy/rust-barycenter | /src/body.rs | UTF-8 | 4,378 | 3.921875 | 4 | [] | no_license | //! # Body
//!
//! Here we define the [`Body`] structure and some functions to calculate weighted averages.
//!
//! # Example
//! ```
//! use barycenter::*
//!
//! let b1 = Body {
//! x: 1.0,
//! y: 10.0,
//! z: 4.0,
//! mass: 100.0
//! };
//!
//! let b2 = Body {
//! x: 2.0,
//! y: 5.0,
//! ... | true |
f6ac2b402da706bb08acd93431ac6e0343da1dec | Rust | input-output-hk/chain-libs | /chain-storage/src/block_store.rs | UTF-8 | 28,805 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
permanent_store::PermanentStore, BlockInfo, ConsistencyFailure, Error, StorageIterator, Value,
};
use sled::{
transaction::{
ConflictableTransactionError, TransactionError, Transactional, TransactionalTree,
},
Tree,
};
use std::path::Path;
#[derive(Clone)]
pub struct BlockStore {
... | true |
d78d2f97769068dd13eb30c83f337f64da12b32f | Rust | sathishvinayk/rust_360 | /generics/linkedlist.rs | UTF-8 | 1,264 | 3.9375 | 4 | [] | no_license | #[derive(Debug)]
struct LinkedList<T> {
head: Option<Box<Node<T>>>
}
#[derive(Debug)]
struct Node<T> {
next: Option<Box<Node<T>>>,
data: T
}
impl<T> LinkedList<T> {
fn new() -> Self {
LinkedList { head: None }
}
fn push_value(&mut self, data: T) {
self.head = Some(Box::new(Node... | true |
88367c4c193a6ff5771c8e690441e59fb06f59b3 | Rust | zackmdavis/Solitairey_Confinement | /src/main.rs | UTF-8 | 868 | 2.765625 | 3 | [] | no_license | mod card;
mod cardpoints;
mod distribution;
mod games;
use card::{Card, Suit, Value};
use games::diamond_mine;
fn main() {
let teaser_card = Card::new(Suit::Spade, Value::Ace);
println!("Welcome to Solitairey Confinement! {}", teaser_card);
let mut game = diamond_mine::DiamondMine::new();
let mut pl... | true |
560287e3fecda33f7d54a3cd33825daf4ae45cf0 | Rust | bazelbuild/rules_rust | /tools/rustdoc/rustdoc_test_writer.rs | UTF-8 | 9,627 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | //! A utility for writing scripts for use as test executables intended to match the
//! subcommands of Bazel build actions so `rustdoc --test`, which builds and tests
//! code in a single call, can be run as a test target in a hermetic manner.
use std::cmp::Reverse;
use std::collections::{BTreeMap, BTreeSet};
use std:... | true |
1dd00cda65a7943da876b2d888e593921e045b1f | Rust | ryota0624/rust_algorithm_picture_book_impl | /src/search.rs | UTF-8 | 584 | 3.03125 | 3 | [] | no_license | mod liner_search;
mod binary_search;
trait Searcher<T: Eq> {
fn exist(self, _: Vec<T>, target: T) -> bool;
}
fn search_test<T: Searcher<i64> + Copy>(sorter: T) {
let sorted = sorter.exist(vec![2, 1, 3], 1);
assert_eq!(sorted, true);
let sorted = sorter.exist(vec![2, 1, 3, 7, 9, 8, 5], 7);
assert_... | true |
232ead60c93676f8d40eb2fc6c8791b3acff1e60 | Rust | kkovaacs/teleport-worker | /client/src/commands.rs | UTF-8 | 3,671 | 2.6875 | 3 | [
"MIT"
] | permissive | use proto::{
job_output::OutputType, start_job_result, status_result, worker_client::WorkerClient, JobId,
JobOutput, JobSubmission, StartJobResult, StatusResult,
};
use anyhow::Result;
use tokio::io::AsyncWriteExt;
use tonic::{transport::Channel, Request};
/// Starts a job
///
/// Returns an optional string t... | true |
7f31aa62e7db8442d24b793c108de5882ca82a20 | Rust | house-of-vanity/unigen | /cli/src/parse_args.rs | UTF-8 | 1,584 | 2.9375 | 3 | [] | no_license | use clap::{App, Arg};
use unigen_lib::{UnitType};
#[derive(Debug)]
pub struct Config {
pub unit_type: UnitType,
pub name: String,
pub description: String,
}
pub fn read() -> Config {
let mut cli_args = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.author(env!("C... | true |
0ed8abfa7073e7c0e002c037bc3a6f59f46317af | Rust | tolgaio/tcpip-rs | /src/icmp/v6.rs | UTF-8 | 1,512 | 3.25 | 3 | [] | no_license | use super::types::ICMPType;
use bitreader::BitReader;
use std::fmt;
#[derive(Debug)]
pub struct ICMP6 {
pub typ: Option<ICMPType>,
pub code: u8,
pub checksum: u16,
pub payload: Vec<u8>,
}
impl ICMP6 {
pub fn new(buf: &[u8]) -> Self {
let mut icmp = Self {
typ: None,
... | true |
337201c526a61102075d976a2b57477a3a7f9943 | Rust | Clikengo/graphql-parser | /src/helpers.rs | UTF-8 | 2,751 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::marker::PhantomData;
use combine::{Parser, ConsumedResult, satisfy, StreamOnce};
use combine::error::{Tracked};
use combine::stream::easy::{Error, Errors, Info};
use tokenizer::{TokenStream, Kind, Token};
use position::Pos;
#[derive(Debug, Clone)]
pub struct TokenMatch<'a> {
kind: Kind,
phantom: Ph... | true |
7ea6c2f88bcad54da5b61addb823ef69842eda6a | Rust | aktoro-rs/aktoro-channel | /src/error.rs | UTF-8 | 5,402 | 3.671875 | 4 | [
"MIT"
] | permissive | #[derive(PartialEq, Eq, Debug)]
/// The error type that is returned by the channels'
/// senders when failing to send data.
pub enum SendError<D> {
/// Returned when the channel's buffer is full.
Full(D),
/// Returned when the sender coudln't send the data
/// because it previously disconnected itself f... | true |
013b0109d4bd1d2a71c30c52468f88df71ae4d3c | Rust | Zerss/osb | /src/utils/vec2.rs | UTF-8 | 2,307 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2021 Thomas Ballasi
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accordin... | true |
aa061c9621b2a6b11a980a66d2c7833af6e54607 | Rust | Nercury/specker-rs | /src/tokens/mod.rs | UTF-8 | 19,322 | 2.734375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2017 Nerijus Arlauskas
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to ... | true |
8e798fa988e70534db9762fe9a724ab79428e412 | Rust | qingyouzhao/weekend_rt | /src/hittable.rs | UTF-8 | 662 | 2.765625 | 3 | [] | no_license | use std::option::Option;
use std::sync::Arc;
use crate::material::Material;
use crate::math::*;
use crate::ray::Ray;
#[derive(Clone, Default)]
pub struct HitRecord {
pub p: Point,
pub normal: Vec3,
pub mat_rc: Option<Arc<dyn Material>>,
pub t: f64,
pub front_face: bool,
}
impl HitRecord {
pub fn set_face... | true |
39535d0ecd69067f150436f93d07fbee20fa5a24 | Rust | songlinshu/stamps | /src/polygonsvg.rs | UTF-8 | 31,258 | 2.984375 | 3 | [] | no_license | // this file deserializes an SVG into a polygon (ignoring a lot of the complicated features of SVG like masks)
use std::path::Path;
use std::collections::HashMap;
use std::vec::Vec;
use super::serde_xml_rs::from_str;
use super::serde_xml_rs;
use std::io::Read;
use std::fmt::Write;
use serde::{Deserialize, Deserializer}... | true |
7d7151c0bbbf443201ccd7edf23cae97f186f36d | Rust | ytyaru/Rust.Document.20190703153427 | /src/0/docs_0/src/lib.rs | UTF-8 | 462 | 3.5 | 4 | [
"CC0-1.0"
] | permissive | //! 本クレートについて
//!
//! このクレートは`cargo doc`を使ってみただけである。
//!
//! * https://doc.rust-jp.rs/book/second-edition/ch14-02-publishing-to-crates-io.html
/// 1を加算した値を返す。
///
/// # 例
///
/// ```
/// assert_eq!(add_one(0), 1);
/// ```
pub fn add_one(x: i32) { x + 1 }
#[cfg(test)]
mod tests {
use super::*;
#[test]
f... | true |
c8c021bcf2a99949c5083b0d51aeeb924e79d8d7 | Rust | aherkelman/rummy_proj | /src/main3.rs | UTF-8 | 791 | 2.921875 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(non_snake_case)]
extern crate rand;
use std::io;
// Card Stuct needs the following:
// Members:
// Card Type - Specific Information related to a card, passed in on creation
// doing this allows for different kinds of cards
/*
mod cards{
use rand;
use rand::Rng;
use st... | true |
f4b4ad1d041f0afdaa366cf032b821a1ecd5bdea | Rust | squidboylan/rsv6 | /kernel/src/serial.rs | UTF-8 | 1,527 | 2.71875 | 3 | [
"MIT"
] | permissive | use core::fmt::{ Write, Result };
use asm::{ outb, inb };
use spin::Mutex;
// COM1 ports
const SERIAL_DATA_PORT: u16 = 0x3F8;
const SERIAL_FIFO_COMMAND_PORT: u16 = 0x3FA;
const SERIAL_LINE_COMMAND_PORT: u16 = 0x3FB;
const SERIAL_MODEM_COMMAND_PORT: u16 = 0x3FC;
const SERIAL_LINE_STATUS_PORT: u16 = 0x3FD;
const SERIA... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.