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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7fef379f35b1d3b74b63f017f97ed24e516dbf27 | Rust | osa1/rhex | /src/gui/hex/hex_grid.rs | UTF-8 | 12,468 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::ptr;
use gui::hex::HexGui;
use colors;
use utils::*;
use term_input::{Arrow, Key};
use termbox_simple::*;
pub struct HexGrid<'grid> {
pos_x: i32,
pos_y: i32,
width: i32,
height: i32,
data: &'grid [u8],
path: &'grid str,
cursor_x: i32,
cursor_y: i32,
scrol... | true |
59cabd8c2706db97dced33d4153484ebaa63f391 | Rust | mehdiraized/tauri | /tauri/src/app/webview_manager.rs | UTF-8 | 9,541 | 2.65625 | 3 | [
"Apache-2.0",
"CC-BY-NC-ND-4.0",
"MIT"
] | permissive | use std::{
collections::HashMap,
future::Future,
sync::{Arc, Mutex},
};
use super::{
event::{EventId, EventPayload},
App, ApplicationDispatcherExt, ApplicationExt, Icon, Webview, WebviewBuilderExt,
WebviewInitializer,
};
use crate::{api::config::WindowUrl, flavors::Wry};
use serde::Serialize;
/// The web... | true |
246ba53af163830b6b4b4f0056bbb644bf46b38c | Rust | ManyTheFish/N-Puzzle | /src/solver.rs | UTF-8 | 7,505 | 3.265625 | 3 | [] | no_license | use std::collections::{HashSet, BinaryHeap};
use std::{error, fmt};
use crate::board::Board;
use crate::state::State;
use crate::tile_move::Move;
use crate::heuristic::Heuristic;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Error {
UnmatchingSizes,
Unsolvable,
}
impl error::Error for Error {
fn ... | true |
3cd98930c03cbb08709dcf96d8b6bc07f9450682 | Rust | wanigame/wani_rogue | /src/game_object_manager.rs | UTF-8 | 1,256 | 2.84375 | 3 | [
"MIT"
] | permissive | //! Struct of game object manager
//!
//! Copyright (c) 2019 wanigame
//!
//! This source code is released under the MIT License
//! http://opensource.org/licenses/mit-license.php
use std::collections::HashMap;
use std::sync::Mutex;
use crate::game_manager::GameManager;
use crate::wani_trait::game_object::GameObject;... | true |
7c24f0730e95b0daf4631e2a96205bedf80fa9da | Rust | kanishkd4/Rust-by-example | /src/bin/c14_generics_functions_impl_traits.rs | UTF-8 | 3,546 | 3.78125 | 4 | [] | no_license | // Generics is the topic of generalizing types and functionalities to broader cases.
// This is useful for reducing code duplication in many cases and but can call for rather involving syntax.
// Being generic requires taking great care to specify over which types a generic type is actually
// considered valid. The si... | true |
a7dbe13f9b621e6c451f11b1add36195483cfa27 | Rust | khonsulabs/rgx-lyon | /examples/path.rs | UTF-8 | 1,781 | 2.796875 | 3 | [
"MIT"
] | permissive | use lyon_tessellation::{math::point, path::Path, FillOptions, StrokeOptions};
use rgx::core::{Blending, Pass, Renderer};
use rgx_lyon::{LyonPipeline, Shape, ShapeBuilder};
mod sandbox;
use sandbox::Sandbox;
fn main() -> Result<(), std::io::Error> {
PathExample::run()
}
struct PathExample {
pipeline: LyonPipe... | true |
5781e7d4118f5b5419abeffbbb3038124f237ed5 | Rust | erikdesjardins/jsssa | /src/opt/tests/forward.rs | UTF-8 | 3,787 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::ir;
use crate::opt::{self, forward};
use crate::swc_globals;
#[test]
fn basic() {
swc_globals::with(|g| {
#[rustfmt::skip]
let ir = {
let a = ir::Ref::new("a");
let b = ir::Ref::new("b");
let c = ir::Ref::new("c");
let d = ir::Ref::new(... | true |
8f339f9124b6701c72dade212ef66311b4d22f34 | Rust | lggruspe/silica | /src/basic.rs | UTF-8 | 4,554 | 2.984375 | 3 | [] | no_license | use crate::env::Environment;
use crate::function::Function;
use crate::interpreter::{Exception, Interpreter};
use crate::object::{Object, ObjectReference};
use crate::value::{Float, Value};
fn assert(_: *mut Interpreter, args: Vec<Value>) -> Result<Vec<Value>, Exception> {
let val = args.first().unwrap_or(&Value::... | true |
8af311a2d227d1f313d84640c00abf65f3429656 | Rust | matsutake-eg/atcoder | /rust/abc185/src/bin/f.rs | UTF-8 | 2,065 | 2.703125 | 3 | [] | no_license | #![allow(unused_imports)]
use itertools::Itertools;
use itertools_num::ItertoolsNum as _;
use num_integer::*;
use petgraph::*;
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;
#[allow(unused)]
const MOD: usize = 1_000_000_007;
// C... | true |
1d94b562d4f4fbfdffd3640e4dbe4ff8ec9280fa | Rust | mwylde/protogen | /src/generator.rs | UTF-8 | 32,869 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use parser::{DataType, Message};
use std::collections::HashMap;
use std::fmt;
use parser::Expression;
use parser::Value;
use parser::Field;
use std::collections::HashSet;
#[cfg(test)]
mod tests {
use super::*;
use parser::{ChooseVariant, Expression, Field, Value};
use parser::Arg;
#[test]
fn test_... | true |
0bf34516a096a68dece33078a054c77a5eaf1daf | Rust | alexmeli100/pbrt-rust | /src/textures/marble.rs | UTF-8 | 2,868 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::core::texture::{TextureMapping3Ds, Texture, TextureMapping3D, fbm, TextureSpec, IdentityMapping3D, TextureFloat};
use crate::core::pbrt::Float;
use crate::core::spectrum::Spectrum;
use crate::core::interaction::SurfaceInteraction;
use crate::core::geometry::vector::Vector3f;
use crate::core::transform::Trans... | true |
ea0e237e0ca1441dbfff955fe2c2055fc890129c | Rust | Buissonix/some-tank-game-rs | /src/components/turret.rs | UTF-8 | 368 | 2.71875 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use bevy::math::Vec3;
#[derive(Copy, Clone, Serialize, Deserialize)]
pub struct Turret {
pub target:Vec3,
pub cooldown:f32,
pub trigger:bool
}
impl Default for Turret {
fn default() -> Self {
Self {
target:Vec3::default(),
cooldown:... | true |
6a230ed462bf929fdd9c677164912f98c88e4208 | Rust | TroyNeubauer/aoc2020 | /src/day9/a.rs | UTF-8 | 1,453 | 3.578125 | 4 | [] | no_license | use std::io::Read;
use std::collections::HashMap;
use std::str::FromStr;
#[test]
fn test() {
let input = String::from(
r#"35
20
15
25
47
40
62
55
65
95
102
117
150
182
127
219
299
277
309
576"#);
assert_eq!(get_bad_number(parse(input), 5, 5).unwrap(), 127);
}
fn get_bad_number(lines: Vec<usize>, pre_length: us... | true |
4ce5207fbf84679e060f03dfff3662c48ec88352 | Rust | wangmarkqi/search_json | /src/process/flat_js.rs | UTF-8 | 2,271 | 2.78125 | 3 | [] | no_license | use crate::common::common::*;
use serde_json::Value;
use std::sync::mpsc::{channel,Sender,Receiver};
use std::thread;
use crate::process::define::*;
fn get_js_value(js: &str) -> Value {
let v = serde_json::from_str(&js);
let res: Value;
match v {
Ok(vv) => res = vv,
Err(_e) => {
... | true |
efc5ff6d7903e323bd968f99d4a104ca73c6dca0 | Rust | matthannah/rust | /rust-by-example/01 - Hello World/Formatted Print/formatting.rs | UTF-8 | 2,543 | 3.84375 | 4 | [] | no_license | // We've seen that formatting is specified via a format string:
// format!("{}", foo) -> "3735928559"
// format!("0x{:X}", foo) -> "0xDEADBEEF"
// format!("0o{:o}", foo) -> "0o33653337357"
// The same variable (foo) can be formatted differently depending on
// which argument type is used: X vs o vs unspecified.
// T... | true |
e33a78edc8c86f965e6c82cdf043cf4e8722437c | Rust | khuey/dkregistry-rs | /src/reference.rs | UTF-8 | 4,994 | 3.46875 | 3 | [] | no_license | //! Parser for `docker://` URLs.
//!
//! This module provides support for parsing image references.
//!
//! ## Example
//!
//! ```rust
//! # extern crate dkregistry;
//! # fn main() {
//! # fn run() -> dkregistry::errors::Result<()> {
//! #
//! use std::str::FromStr;
//! use dkregistry::reference::Reference;
//!
//! //... | true |
86c2b9ae12d079929ca036478c026db0a9163950 | Rust | HarrisonMc555/exercism | /rust/prime-factors/src/lib.rs | UTF-8 | 562 | 3.046875 | 3 | [] | no_license | use integer_sqrt::IntegerSquareRoot;
use slow_primes::Primes;
pub fn factors(n: u64) -> Vec<u64> {
let max_factor = n.integer_sqrt();
let sieve = Primes::sieve(max_factor as usize);
let mut prime_factors = Vec::new();
let mut num = n;
for prime in sieve.primes() {
let prime = prime as u64;
... | true |
6ffcec5d2a55d3f359dc4a4a29268daba9874065 | Rust | SjB/emacs-module-rs | /src/error.rs | UTF-8 | 4,775 | 2.84375 | 3 | [] | no_license | use std::result;
use std::error;
use std::io;
use std::ffi::NulError;
use emacs_module::*;
use super::{Env, Value};
use super::IntoLisp;
/// We assume that the C code in Emacs really treats it as an enum and doesn't return an undeclared
/// value, but we still need to safeguard against possible compatibility issue (E... | true |
1b77b87a1f34b69ff96cd4dfd73346c595f21992 | Rust | y-usuzumi/survive-the-course | /survive-the-course-rs/macro-playground/src/assert_eq.rs | UTF-8 | 1,659 | 3.59375 | 4 | [
"BSD-3-Clause"
] | permissive | // This is a bad implementation because Rust expands the fragments $a and $b as
// is provided by the caller. This means expressions that mutate values may cause
// side effects, for example `bad_assert_eq1!(some_vec.pop(), some_value)`
macro_rules! bad_assert_eq1 {
($a:expr, $b:expr) => {
if $a != $b {
... | true |
820b1c498b3b84c49ac5f7ee6adc559cb94a4a9a | Rust | brnkes/2019-aoc-stuff | /d11/src/interpreter.rs | UTF-8 | 10,710 | 2.984375 | 3 | [] | no_license | //#![feature(trace_macros)]
//trace_macros!(true);
use std::borrow::{Borrow, BorrowMut};
use std::cell::{Cell, RefCell};
use std::collections::VecDeque;
use std::rc::Rc;
#[derive(PartialEq)]
#[derive(Debug)]
enum Op {
Sum,
Mul,
End,
Input,
Output,
JumpIfTrue,
JumpIfFalse,
LessThan,
... | true |
4f7be334ecb341f9e0ca7b3fbf671a390183357e | Rust | TamplierS1/rox | /src/error.rs | UTF-8 | 1,103 | 3.4375 | 3 | [] | no_license | pub mod err
{
use std::fmt::{self, Formatter};
use std::io::{self, Write};
#[derive(Debug)]
pub enum Error
{
CompileError(String),
RuntimeError(String),
}
pub fn error(error: self::Error)
{
// This function should not return anything,
// that's why I'm u... | true |
24f72587615ee5d9f832ce4017a8245e5b7f12da | Rust | srijs/rust-cfn | /src/aws/robomaker.rs | UTF-8 | 52,782 | 3.0625 | 3 | [
"MIT"
] | permissive | //! Types for the `RoboMaker` service.
/// The [`AWS::RoboMaker::Fleet`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-robomaker-fleet.html) resource type.
#[derive(Debug, Default)]
pub struct Fleet {
properties: FleetProperties
}
/// Properties for the `Fleet` resource.
#[derive(Debu... | true |
dad48154977017ff183516fb7d6054e6ba9d8cbf | Rust | omegablitz/distributary | /tests/lib.rs | UTF-8 | 39,300 | 2.625 | 3 | [] | no_license | extern crate distributary;
use std::time;
use std::thread;
use std::sync::mpsc;
use std::collections::HashMap;
#[test]
fn it_works() {
// set up graph
let mut g = distributary::Blender::new();
let (a, b, cq) = {
let mut mig = g.start_migration();
let a = mig.add_ingredient("a", &["a", "b"... | true |
454101a83965ac6759f282a5909c0e3b26b75e3c | Rust | EFanZh/LeetCode | /src/problem_0902_numbers_at_most_n_given_digit_set/mod.rs | UTF-8 | 604 | 3.1875 | 3 | [] | no_license | pub mod iterative;
pub trait Solution {
fn at_most_n_given_digit_set(digits: Vec<String>, n: i32) -> i32;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [
(("1357", 100), 20),
(("149", 1_000_000_000), 29523),
(("7",... | true |
6f3ec60798e73296db8eb026c11fa0fe6eb86475 | Rust | MarkMcCaskey/rust-lisp | /src/ast.rs | UTF-8 | 3,142 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use types::*;
#[derive(Debug)]
pub struct Program(Vec<Form>);
#[derive(Debug, Clone)]
pub enum Form {
Def(Definition),
Expr(Expression),
}
#[derive(Debug, Clone)]
pub enum Definition {
Variable(VariableDefinition),
//Syntax(SyntaxDefinition),
BeginDefinitions(Vec<Definition>),
LetSyntax(Vec<S... | true |
d64c1dd2bad1499902ddad5ddf70f65824c9ba44 | Rust | getsentry/symbolic | /symbolic-symcache/src/writer.rs | UTF-8 | 21,730 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Defines the [SymCache Converter](`SymCacheConverter`).
use std::collections::btree_map;
use std::collections::BTreeMap;
use std::io::Write;
use indexmap::IndexSet;
use symbolic_common::{Arch, DebugId};
use symbolic_debuginfo::{DebugSession, FileFormat, Function, ObjectLike, Symbol};
use watto::{Pod, StringTable, ... | true |
7666a59f5dbbbe224f9c135c471e12dae917114a | Rust | HyperionSuperNova/ProjectEuler100Challenge | /Problem4.rs | UTF-8 | 629 | 3.40625 | 3 | [] | no_license | fn is_palindrome(n:i128) -> bool{
let s: String = n.to_string();
if s.len() == 0 {return true;}
let s:Vec<char> = s.chars().collect();
let mut i = 0;
let mut j = s.len() - 1;
while i < j {
if s[i] != s[j]{ return false;}
i+=1;
j-=1;
}
return true;
}
fn compute_so... | true |
3e27effd081b9ad45a143352f39696b50b68b5e6 | Rust | FeodalherreN/codeabbey_rs | /src/tasks/dice_rolling.rs | UTF-8 | 678 | 3.609375 | 4 | [] | no_license | fn dice_rolling(random_floats: Vec<f32>) -> String {
let mut answer: Vec<String> = Vec::new();
for float in random_floats.iter() {
let random = (float * 6.0 + 1.0) as i32;
answer.push(random.to_string());
}
answer.join(" ")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
f... | true |
d85e19d6bfef98160a3c6e61a01940e6c11b0b90 | Rust | Parodix007/TiABD-proj | /db_conn/src/struct_of_examined_problem.rs | UTF-8 | 1,544 | 3.1875 | 3 | [] | no_license | #[derive(Debug)]
pub struct FirstProblem {
avg_with_where: f32,
avg_with_group_by: f32,
time_of_creating_index:f32,
}
impl FirstProblem {
pub fn new(avg_with_where: f32, avg_with_group_by: f32, time_of_creating_index: f32) -> Self {
Self {
avg_with_where,
avg_with_group_by,
time_of_creating_index,
}
}... | true |
4cb0cf93330d4ad8b84172959218f84aa46d4dda | Rust | Rukenshia/dutrack-rs | /src/routes/assets/mod.rs | UTF-8 | 350 | 2.546875 | 3 | [] | no_license | use std::path::{Path, PathBuf};
use rocket::Rocket;
use rocket::response::NamedFile;
mod favicon;
#[get("/<file..>")]
fn asset(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("assets/").join(file)).ok()
}
pub fn mount(rocket: Rocket) -> Rocket {
rocket.mount("/", routes![favicon::get]).mount... | true |
70f724f614046e85cf545cc62dae855ff14db6bc | Rust | dbp/rustle | /types.rs | UTF-8 | 9,209 | 3.46875 | 3 | [] | no_license | //! This file contains type definitions
use std::treemap::*;
type Set<T: Copy Ord> = TreeMap<T,()>;
use core::cmp::{Eq, Ord};
// Note that we are using treemaps to get unordered comparison.
// because vecs are much more supported, we only convert to sets
// when we compare. this is inefficient, but intended to be te... | true |
f902b3acb9efbc0478d20da8fccb4b58ecd50493 | Rust | abhimadan/raytracer | /src/geometry/sphere.rs | UTF-8 | 1,407 | 3.125 | 3 | [] | no_license | use super::vec::Vec3;
use super::ray::Ray;
pub struct Sphere {
pub center: Vec3,
pub radius: f64,
pub colour: Vec3,
}
impl Sphere {
pub fn from(center: Vec3, radius: f64, colour: Vec3) -> Sphere {
Sphere {
center,
radius,
colour,
}
}
pub fn ... | true |
d20e06f6f35e085fb86cd457eb9b3bc30962b07a | Rust | davidmoreno/nui-1 | /src/blocks/filter2.rs | UTF-8 | 3,245 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use audiobuffer::*;
use port::Port;
use processblock::ProcessBlock;
use synthconfig::SynthConfig;
#[derive(Debug)]
pub struct Filter2{
sample_rate: f32,
a1:f32,
a2:f32,
a3:f32,
b1:f32,
b2:f32,
out1:f32,
out2:f32,
in1:f32,
in2:f32,
}
pub const INPUT:Port = Port{nr:0};
pub cons... | true |
4052322b6d9d300c295edd7a0d152e330c8182be | Rust | boybird/adblock-rust | /src/utils.rs | UTF-8 | 12,277 | 3.015625 | 3 | [] | no_license | use std::io::{BufRead, BufReader};
use std::fs::File;
use fasthash::xx as hasher;
pub type Hash = u32;
static HASH_MAX: Hash = std::u32::MAX;
// #[inline]
// pub fn fast_hash(input: &str) -> Hash {
// // originally uses DJB2 hash
// let mut hash: Hash = 5381;
// let mut chars = input.chars();
// whil... | true |
65dc56d34620d971df66d094c97801dcd2ed89df | Rust | gorilskij/truth_table | /src/internals/parse.rs | UTF-8 | 6,890 | 3.296875 | 3 | [] | no_license | use crate::internals::expression::Expr;
use std::ops::RangeBounds;
use std::collections::Bound;
use crate::internals::var_values::VarValues;
fn split(from: &str) -> Vec<String> {
let mut parts = vec![];
let mut part = String::new();
let mut last: Option<char> = None;
for ch in from.chars() {
m... | true |
b91ce95d79b8b70b39a82c5b30adc21f94726821 | Rust | rowhit/scirust | /srmatrix/src/traits.rs | UTF-8 | 9,217 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | #![doc="Traits for matrices
"]
// Standard library imports
use std::cmp;
use num::{Float};
// external imports
use num::traits::{Signed};
// local imports
use sralgebra::{MagmaBase, CommutativeMonoidAddPartial,
CommutativeMonoidMulPartial,
FieldPartial};
use matrix::Matrix;
use error::SRError;
... | true |
c354b718ffbe579c70c762a3884ca6daf4a8a06e | Rust | colbyn/view-prototype | /src/html.rs | UTF-8 | 18,960 | 2.71875 | 3 | [] | no_license | use std::fmt;
use std::fmt::Debug;
use std::convert::From;
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::BTreeMap;
use std::collections::VecDeque;
use std::cell::{self, Cell, RefCell};
use std::rc::Rc;
use either::Either;... | true |
247ca7b6af80bccb0af5b2000da44d0a6736681c | Rust | UMASHIBA1/AtCoderPractice | /20_3_28_abc160/d_line_plus_plus/src/main.rs | UTF-8 | 316 | 2.734375 | 3 | [] | no_license | use std::io;
fn main() {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer).unwrap();
let target_input: Vec<i64> = buffer
.trim()
.split_whitespace()
.map(|c| c.parse().unwrap())
.collect();
for i in target_input {
println!("{}", i);
}
}
| true |
853e2578d2a9fa1f6314e0a8648cd142c1687fde | Rust | wezm/add-media-dimensions | /src/main.rs | UTF-8 | 2,482 | 2.921875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::process::Command;
use std::{env, fs, io};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Serialize, Deserialize)]
struct Tweet {
url: String,
author_name: String,
author_url: String,
html: String,
width: u32,
height: Option<u32>,
#[serde(rename = "type")]
... | true |
853d4e737b608399d63c4874739a7f71ac06fedf | Rust | philmein23/interpreter | /src/lexer/mod.rs | UTF-8 | 7,813 | 3.59375 | 4 | [] | no_license | use crate::token::{lookup_identifier, Token};
use std::char;
#[derive(Debug)]
pub struct Lexer {
input: String,
position: usize,
read_position: usize,
ch: char,
}
impl Lexer {
pub fn new(input: String) -> Lexer {
let mut lexer = Lexer {
input,
position: 0,
... | true |
ac0490d4356a317e9ab3bc5a2a058e7824304609 | Rust | fernandobatels/blitz-explorer | /src/tcp/request.rs | UTF-8 | 3,869 | 2.875 | 3 | [
"MIT"
] | permissive | ///
/// Blitz Explorer
///
/// Request on the tcp server
///
/// Copyright 2019 Luis Fernando Batels <luisfbatels@gmail.com>
///
use std::net::{TcpStream, SocketAddr};
use std::io::{BufReader, BufRead, Write, BufWriter, copy};
use catalog::catalog::Catalog;
pub struct Request {
}
impl Request {
// Handle the c... | true |
93c8999ec04970700973341cf49c2862515d494d | Rust | jasilven/aoc-2019-rust | /src/bin/day10.rs | UTF-8 | 3,526 | 3.125 | 3 | [] | no_license | use anyhow::Result;
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
mod float64;
use float64::F64;
fn parse_input(path: &str) -> Result<HashSet<(usize, usize)>> {
let mut result = HashSet::new();
let f = File::open(path)?;
let reader = BufReader::... | true |
d40d29c8c7321eaa76338e75e3dce9fb6d736997 | Rust | sinhrks/brassfibre | /src/frame/reshape.rs | UTF-8 | 2,599 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | use std::borrow::{Borrow, Cow};
use std::hash::Hash;
use nullvec::prelude::Array;
use nullvec::prelude::Append as NullVecAppend;
use super::DataFrame;
use algos::join::{JoinOp, HashJoin};
use indexer::Indexer;
use traits::{Slicer, RowIndex, Append, Concatenation, Join};
impl<'v, 'i, 'c, I, C> Append<'c> for DataFra... | true |
9baae2dd82298069269a0d50bcd87a58f8e2755c | Rust | nikomatsakis/rust | /src/comp/syntax/codemap.rs | UTF-8 | 8,644 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"bzip2-1.0.6",
"BSD-1-Clause"
] | permissive | import core::{vec, uint, str, option, result};
import std::{term, io};
import io::writer_util;
import option::{some, none};
type filename = str;
type file_pos = {ch: uint, byte: uint};
/* A codemap is a thing that maps uints to file/line/column positions
* in a crate. This to make it possible to represent the posit... | true |
8ad827d2743ef18c8486f49d8e2b7629d566d313 | Rust | goodrone/project-euler-rust | /031/main.rs | UTF-8 | 963 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn _num_ways(
t: u64,
alphabet: &[u64],
cache: &mut HashMap<(u64, u64), usize>) -> usize
{
if alphabet.len() == 0 {
return 0;
}
let r = cache.get(&(t, alphabet[0]));
if r.is_some() {
return *r.unwrap();
}
if t < alphabet[0] {
re... | true |
6cdc16f6f63e2723abc26e4d642b877848a82595 | Rust | mstallmo/paste.rs | /src/api/mod.rs | UTF-8 | 1,141 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::database::actions::pastes;
use crate::database::DbConn;
use rocket::Data;
use std::io::Read;
#[get("/docs")]
fn index() -> &'static str {
"\
USAGE
POST api/v1/
accepts raw data in teh body of the request and responds with a URL of
a page containing the body's content... | true |
546d2cb118a188f9545daf98f5de8e8c742e59e1 | Rust | yaahc/nostd-error-poc | /fakecore/src/result.rs | UTF-8 | 1,184 | 2.859375 | 3 | [] | no_license | use crate::track::Track;
use core::panic::Location;
pub enum Result<T, E> {
Ok(T),
Err(E),
}
impl<T, E> Result<T, E> {
pub fn unwrap_err(self) -> E {
match self {
Self::Ok(_) => panic!(),
Self::Err(e) => e,
}
}
}
// impl<T, E> core::ops::Try for Result<T, E> {
... | true |
1990c6b5b514598f186a04b2051cae2c2b06373b | Rust | dtynn/learning | /leetcode-rs/p0329_longest_increasing_path_in_a_matrix/src/lib.rs | UTF-8 | 3,607 | 3.34375 | 3 | [] | no_license | pub struct Solution {}
use std::collections::BTreeSet;
impl Solution {
pub fn longest_increasing_path(matrix: Vec<Vec<i32>>) -> i32 {
let row_size = matrix.len();
if row_size == 0 {
return 0;
}
let col_size = matrix[0].len();
let mut path = vec![];
let ... | true |
2c105a7f3f5bc44d0a67e484e518344ddcb2b89a | Rust | xyz-airmash/airmash-server | /ctf/src/systems/timer/set_game_active.rs | UTF-8 | 996 | 2.59375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use specs::*;
use server::component::channel::*;
use server::*;
use component::*;
use consts::*;
/// Resets game score to 0-0 when the
/// game starts.
#[derive(Default)]
pub struct SetGameActive {
reader: Option<OnTimerEventReader>,
}
#[derive(SystemData)]
pub struct SetGameActiveData<'a> {
channel: Read<'a, OnT... | true |
fe20b1385834bc5ae3bd367bcf12ab86986e29bf | Rust | dimforge/nalgebra | /nalgebra-glm/src/vector_relational.rs | UTF-8 | 5,662 | 3.75 | 4 | [
"Apache-2.0"
] | permissive | use crate::aliases::TVec;
use crate::traits::Number;
/// Checks that all the vector components are `true`.
///
/// # Examples:
///
/// ```
/// # use nalgebra_glm as glm;
/// let vec = glm::vec2(true, false);
/// assert_eq!(false, glm::all(&vec));
///
/// let vec = glm::vec2(true, true);
/// assert_eq!(true, glm::all(&... | true |
bbc20859fd061c258dd2166625503ec0d4df78d5 | Rust | hypen-emdash/Turing-Machine-Simulator | /src/turing_machine.rs | UTF-8 | 12,605 | 3.28125 | 3 | [] | no_license | use crate::{
program::{Goto, Response, TransitionFn},
tape::Tape,
};
use std::{fmt, fmt::Debug, marker::PhantomData};
#[derive(Debug)]
pub struct TuringMachine<State, Alphabet, TapeImpl, Program> {
state: Goto<State>,
prog: Program,
tape: TapeImpl,
phantom: PhantomData<Alphabet>,
}
impl<State,... | true |
81f1ac68b5ed967c5fb8b017e747264bdd5dca2c | Rust | SiegeEngine/siege-example-net | /src/packet/login.rs | UTF-8 | 1,443 | 2.828125 | 3 | [
"MIT"
] | permissive |
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[repr(C)]
pub struct LoginPacket {
pub login: String,
pub password: String,
}
impl LoginPacket {
pub fn new(login: String, password: String) -> LoginPacket
{
LoginPacket {
login: lo... | true |
9b2fdfb15dd63d6d06f4ac99ef3e618221031dd4 | Rust | ein-lang/ein | /lib/lang/src/ast/operation.rs | UTF-8 | 2,943 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | use super::{
arithmetic_operation::ArithmeticOperation, boolean_operation::BooleanOperation,
equality_operation::EqualityOperation, expression::Expression, order_operation::OrderOperation,
pipe_operation::PipeOperation,
};
use crate::{debug::SourceInformation, types::Type};
use std::sync::Arc;
#[derive(Clo... | true |
d4731722630ca15efd6d086d636edb9a4a3a1d98 | Rust | tiny-http/tiny-http | /src/test.rs | UTF-8 | 3,796 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::{request::new_request, HTTPVersion, Header, HeaderField, Method, Request};
use ascii::AsciiString;
use std::net::SocketAddr;
use std::str::FromStr;
/// A simpler version of [`Request`] that is useful for testing. No data actually goes anywhere.
///
/// By default, `TestRequest` pretends to be an insecure GE... | true |
5e334dfbb36635dc4a5b06c165c85b7d86f8cbbe | Rust | shirow-github/mirakc | /mirakc-core/src/string_table.rs | UTF-8 | 2,416 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fs::File;
use std::sync::Arc;
use serde::Deserialize;
use serde_yaml;
pub fn load(path: &str) -> Arc<StringTable> {
let reader = File::open(path)
.unwrap_or_else(|err| panic!("Failed to open {}: {}", path, err));
let string_table: StringTable = serde_yaml::from_reader(reader)
.unwrap_... | true |
20c4890bb74d5cb32703861589e61969273f9ce0 | Rust | isgasho/pg-schema-diff | /src/nodes/a_const.rs | UTF-8 | 842 | 2.515625 | 3 | [] | no_license | use crate::schema_set::Sql;
use postgres_parser::nodes::A_Const;
impl Sql for A_Const {
fn sql(&self) -> String {
let mut sql = String::new();
if let Some(i) = self.val.int.as_ref() {
sql.push_str(&i.to_string());
} else if let Some(s) = self.val.string.as_ref() {
s... | true |
a3a57913785e6bc23e66cb748b00f1de924fb6fa | Rust | jamiebidelia/star_slammers | /src/tile_map.rs | UTF-8 | 2,692 | 2.5625 | 3 | [
"Unlicense"
] | permissive | /*
_____ _ _____ _
/ ____| | / ____| | _
| (___ | |_ __ _ _ __ | (___ | | __ _ _ __ ___ _ __ ___ ___ _ __ ___(_)
\___ \| __/ _` | '__| \___ \| |/ _` | '_ ` _ \| '_... | true |
64de23eb8c318199dfe1ea84445282364b576a19 | Rust | herveDarritchon/hurl | /src/format/color.rs | UTF-8 | 1,539 | 3.484375 | 3 | [] | no_license | pub enum TerminalColor {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
LightGray,
LightBlack,
LightRed,
LightGreen,
LightYellow,
LightBlue,
LightMagenta,
LightCyan,
LightWhite,
}
impl TerminalColor {
pub fn format(self, v: String) -> String {
... | true |
fc30fb07040f5b51d629c13139acd0e8e7dc0100 | Rust | brianchin/rust-openssl | /openssl/src/types.rs | UTF-8 | 1,252 | 3.296875 | 3 | [
"Apache-2.0",
"OpenSSL",
"MIT",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows"
] | permissive | //! Items used by other types.
/// A type implemented by wrappers over OpenSSL types.
///
/// This should not be implemented by anything outside of this crate; new methods may be added at
/// any time.
pub trait OpenSslType: Sized {
/// The raw C type.
type CType;
/// The type representing a reference to ... | true |
a7c1175b3b4f57eac6b9f9b17652b52fde7ef945 | Rust | czipperz/pizza-injection | /src/ingredients.rs | UTF-8 | 464 | 2.5625 | 3 | [] | no_license | #[derive(Debug)]
pub enum Veggies {
BlackOlives,
Eggplant,
Garlic,
Mushroom,
Onion,
RedPepper,
Spinach,
}
#[derive(Debug)]
pub enum Cheese {
Mozzarella,
Parmesan,
Reggiano,
}
#[derive(Debug)]
pub enum Clams {
Fresh,
Frozen,
}
#[derive(Debug)]
pub enum Dough {
Thick... | true |
113c3822750831ce8d746a2d005d661b44436705 | Rust | prakhar1989/exercism | /rust/sieve/src/lib.rs | UTF-8 | 691 | 3.140625 | 3 | [] | no_license | pub fn primes_up_to(upper_bound: u64) -> Vec<u64> {
if upper_bound < 2 {
return Vec::new();
}
let upper_bound = upper_bound as usize;
let size = upper_bound + 2; // +2 is to handle 0 and 1 at their indices
let mut all: Vec<bool> = Vec::with_capacity(size);
all.resize(size, true);
... | true |
ff93ee6d65be527d38be5a6ec48712d3b7ba5f9a | Rust | iqlusioninc/yubihsm.rs | /src/mockhsm/object.rs | UTF-8 | 1,506 | 2.640625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Objects stored inside of the `MockHsm`
#![allow(unknown_lints, renamed_and_removed_lints, too_many_arguments)]
mod objects;
mod payload;
pub(crate) use self::{objects::Objects, payload::Payload};
use crate::{object, Algorithm};
use serde::{Deserialize, Serialize};
/// Label for the default auth key
const DEFAUL... | true |
9bfead8470d793034fff146f555633e8ee78ca54 | Rust | sirkibsirkib/multiplayer_serv | /src/engine/client_game/asset_manager.rs | UTF-8 | 3,111 | 2.75 | 3 | [] | no_license | use std::collections::HashMap;
use ::identity::*;
use super::piston_window::{G2dTexture,Texture,TextureSettings,Flip};
use super::piston_window::ImageSize;
use ::gfx_device_gl::Factory;
use std::path::{Path,PathBuf};
use ::saving::SaverLoader;
pub struct HardcodedAssets {
pub planet_mask: G2dTexture,
}
impl Hardc... | true |
505020c2a64206e2d5e9d1db4b7c85094e516f08 | Rust | pluripotency/rust-sorting | /src/merge_recurse_rosetta.rs | UTF-8 | 1,255 | 3.375 | 3 | [] | no_license | fn merge<T: Copy + PartialOrd>(x1: &[T], x2: &[T], y: &mut [T]) {
let mut i = 0;
let mut j = 0;
let mut k = 0;
while i < x1.len() && j < x2.len() {
if x1[i] < x2[j] {
y[k] = x1[i];
k += 1;
i += 1;
} else {
y[k] = x2[j];
k += 1;
... | true |
197497ddc7f0350d9c26548814d3c2a7e0dd5991 | Rust | candy-lang/candy | /compiler/cli/src/utils.rs | UTF-8 | 2,043 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::Exit;
use candy_frontend::module::{Module, ModuleFromPathError, ModuleKind, PackagesPath};
use std::{
env::{current_dir, current_exe},
path::PathBuf,
};
use tracing::error;
pub fn packages_path() -> PackagesPath {
// We assume the candy executable lives inside the Candy Git repository
// ins... | true |
81b21ae2318be3df26bd8d2202e6a42b8cea5d62 | Rust | gnoliyil/fuchsia | /src/developer/ffx/config/src/storage.rs | UTF-8 | 35,940 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::api::query::SelectMode,
crate::environment::Environment,
crate::nested::{nested_get, nested_remove, nested_set},
crate::Config... | true |
a365ba225ab1c4b26a0e73e15763d55b5c18822d | Rust | BroderickCarlin/embedded-graphics | /tinybmp/tests/embedded_graphics.rs | UTF-8 | 2,909 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use embedded_graphics::{
image::Image,
mock_display::{ColorMapping, MockDisplay},
pixelcolor::{Gray8, Rgb555, Rgb565, Rgb888},
prelude::*,
primitives::Rectangle,
};
use tinybmp::Bmp;
#[test]
fn negative_top_left() {
let image: Bmp<Rgb565> =
Bmp::from_slice(include_bytes!("./chessboard-4... | true |
a064ea89e0ba6aad8c31d4e18265c013f1fea95d | Rust | mkehrt/aoc2020 | /day-9/src/main.rs | UTF-8 | 1,115 | 3.0625 | 3 | [] | no_license | use std::{
env,
fs::File,
io::{BufRead, BufReader},
path::Path,
};
fn main() {
let args: Vec<String> = env::args().collect();
let input = Path::new(&args[1]);
let file = File::open(input).unwrap();
let reader = BufReader::new(file);
let vals: Vec<i64> = reader
.lines()
... | true |
1e4b414ffb9e3ee228372957ebfb5029057e6ba0 | Rust | embedded-graphics/embedded-graphics | /src/text/renderer/character_style.rs | UTF-8 | 1,252 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::{pixelcolor::PixelColor, text::DecorationColor};
/// Character style.
///
/// This trait is used to modify character styles programmatically, for example, to implement
/// rendering of text with multiple colors. Applications shouldn't use this trait and instead use
/// the character style types that are pro... | true |
727627a5b20aa37622bf7509038ef21ddcbb6504 | Rust | gutrse3321/rusty-crabs | /tests/src/lib.rs | UTF-8 | 1,605 | 3.890625 | 4 | [] | no_license | #[cfg(test)]
mod tests {
use crate::Rectangle;
#[test]
fn it_works() {
// 使用assert_eq! 测试判断运算与第二个参数结果值是否相等
// 不相等将panic!
assert_eq!(2 + 2, 4);
}
#[test]
fn it_works_result() -> Result<(), String> {
if 2 + 2 == 6 {
Ok(())
} else {
... | true |
1f270ee20a6bd8e82fbb382ac7f0e88e24fee239 | Rust | kecci/rust-functions | /src/main.rs | UTF-8 | 1,328 | 4.125 | 4 | [] | no_license | // Functions
fn hello() {
println!("Hello everyone!");
}
fn hello_world() {
println!("Hello world!");
}
// Functions Parameters
fn user(age: u8, name: String) {
println!("I'm {} years old. My name is {}", age, name);
}
// Return Values
fn sum_two_values(number1: i32, number2: i32) -> i32 {
return num... | true |
f4d2ae3611ddb12ffe6709c9867a4486ddfabd61 | Rust | mtrp12/fp-core.rs | /fp-examples/src/setoid_example.rs | UTF-8 | 167 | 2.75 | 3 | [
"MIT"
] | permissive | use fp_core::setoid::*;
#[test]
fn setoid_example() {
assert_eq!(vec![1, 2].equals(&vec![1, 2]), true);
assert_eq!(Setoid::equals(&"test", &"test"), true);
}
| true |
0a8104ea556627289be6c90d63920793c3a305af | Rust | thomascsd/rust-learning-note | /basic/src/main.rs | UTF-8 | 329 | 3.578125 | 4 | [] | no_license | fn main() {
// loop
let mut count = 0;
let result = loop {
count += 1;
if count == 20 {
break count * 2;
}
};
println!("Result is {}", result);
// for
let list = [22, 33, 88, 66, 55];
for item in list.iter() {
println!("item is {}", item);... | true |
6e45fd617d9c2eec709ae6ad714302b771b3f78e | Rust | KaoImin/rbatis | /src/sql/rule.rs | UTF-8 | 2,084 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use crate::DriverType;
pub trait SqlRule {
fn make_where(&self, where_sql: &str) -> String {
let sql = where_sql.trim_start();
if sql.is_empty() {
return String::new();
}
if sql.starts_with(crate::sql::TEMPLATE.order_by.right_space)
|| sql.starts_with(crate::... | true |
253b4fd3da6faecb2d189170237c3c5e3aa5e640 | Rust | 1010Tom/itchysats | /daemon/src/bitmex_price_feed.rs | UTF-8 | 3,726 | 3.09375 | 3 | [] | no_license | use crate::model::{Price, Timestamp};
use anyhow::Result;
use futures::{StreamExt, TryStreamExt};
use rust_decimal::Decimal;
use std::convert::TryFrom;
use std::future::Future;
use tokio::sync::watch;
use tokio_tungstenite::tungstenite;
/// Connects to the BitMex price feed, returning the polling task and a watch chan... | true |
c9c12adffc8f23623f9396c8588e1dd0dc9f9b09 | Rust | NaomiLea/ji-cloud | /frontend/apps/crates/utils/src/math/point.rs | UTF-8 | 1,962 | 3.875 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | #[derive(Debug, Clone, Copy)]
pub struct PointI32 {
pub x: i32,
pub y: i32
}
impl PointI32 {
pub fn new(x: i32, y: i32) -> Self {
Self {x, y}
}
}
//TODO - simplify these with macros
impl std::ops::Sub for PointI32 {
type Output = Self;
fn sub(self, other: Self) -> Self {
Self... | true |
ada0bf6679300eaf1e75e1da0019ec06a909f7a4 | Rust | archetect/archetect | /archetect-core/src/vendor/read_input/mod.rs | UTF-8 | 11,446 | 2.859375 | 3 | [
"MIT"
] | permissive | //! Go the the [readme](https://crates.io/crates/read_input) file for extra documentation and tutorial.
#![deny(clippy::pedantic, missing_docs)]
#![allow(clippy::must_use_candidate)]
// `impl ToString` is better than `&impl ToString`. Clippy is not ready for impl trait.
#![allow(clippy::needless_pass_by_value)]
use s... | true |
292a7414b15e4a57ccba91d61c312644dba9d8df | Rust | noobLue/tmc-langs-rust | /tmc-langs/src/submission_processing.rs | UTF-8 | 17,664 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Functions for processing submissions.
use crate::error::LangsError;
use lazy_static::lazy_static;
use regex::Regex;
use std::path::Path;
use tmc_langs_framework::{MetaString, MetaSyntaxParser};
use tmc_langs_util::file_util;
use walkdir::{DirEntry, WalkDir};
lazy_static! {
static ref FILES_TO_SKIP_ALWAYS: Reg... | true |
b0e050cb165865ef406754a3ea729713eec5724f | Rust | AndrewTweddle/CodingExercises | /AdventOfCode/aoc2021/src/bin/day10_problem2.rs | UTF-8 | 4,051 | 3.34375 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, Read};
fn main() {
let input_file = File::open("data/day10_input").unwrap();
let mut br = BufReader::new(input_file);
let mut text = String::new();
br.read_to_string(&mut text).unwrap();
let part1_score: u64 = score_part1(text.as_str());
println!("Par... | true |
054dd494942b0edfb612e3875c77e8e1bbd2fbdd | Rust | javinovo/rust-basics | /lifetimes/src/main.rs | UTF-8 | 3,074 | 4.3125 | 4 | [] | no_license | #[allow(dead_code)]
// Conceptos: borrow checker, lifetime annotation, static lifetime, lifetime elision
// Every reference has a lifetime. Some are either implicit or inferred but some times we have to explicitly tell the compiler.
// The main aim of lifetimes is to prevent dangling references, which will cause a p... | true |
d8b0090b95090a2b01963a7e9f17f003b2674985 | Rust | n4to4/aoc-2018 | /aoc1-3/src/day3.rs | UTF-8 | 3,666 | 3.3125 | 3 | [] | no_license | use regex::Regex;
type Result<T> = std::result::Result<T, Box<std::error::Error>>;
const MAX_ID: usize = 2048;
const BOARD_SIZE: usize = 1024;
#[derive(Debug, PartialEq, Eq)]
struct Claim {
id: usize,
x: usize,
y: usize,
width: usize,
height: usize,
}
#[aoc_generator(day3)]
fn input_generator(in... | true |
2f541c4212482b7941a87539b6ba3fec00eaa128 | Rust | Alan19922015/glacio | /glacio-http/src/atlas/status.rs | UTF-8 | 7,579 | 2.796875 | 3 | [] | no_license | use Result;
use atlas::Config;
use glacio::atlas::{Efoy, Heartbeat, efoy};
use std::collections::BTreeMap;
/// An ATLAS status report.
#[derive(Debug, Serialize)]
pub struct Status {
/// The date and time that the last heartbeat was received.
pub last_heartbeat_received: String,
/// A list of battery statu... | true |
92b888d5ada69c9a257ed915547aa282e652f54d | Rust | jblebrun/wrausmt | /src/runtime/exec.rs | UTF-8 | 18,077 | 2.53125 | 3 | [
"MIT"
] | permissive | use super::{
error::RuntimeError,
values::{Ref, Value},
Runtime,
};
use super::{
error::{Result, TrapKind},
store::addr,
};
use crate::runtime::instance::MemInstance;
use crate::runtime::stack::Label;
use crate::{impl_bug, instructions::exec_method};
use crate::{logger::Logger, types::RefType};
use ... | true |
8f8551cde54a10378f9431a4386d17058568a33e | Rust | Tismas/aoc2020 | /src/day1/mod.rs | UTF-8 | 1,779 | 3.359375 | 3 | [] | no_license | use crate::utils;
use std::path::PathBuf;
fn find_sum_equal(elements: &Vec<i32>, sum: i32) -> Option<(i32, i32)> {
let mut sorted = elements.clone();
sorted.sort();
let mut left = 0;
let mut right = sorted.len() - 1;
while left != right {
let left_val = sorted[left];
let right_val... | true |
e7cb2b78903b196e32c68b20fffdf51095a7ada7 | Rust | jD91mZM2/lcs | /examples/diff.rs | UTF-8 | 982 | 2.8125 | 3 | [
"MIT"
] | permissive | extern crate lcs;
use lcs::{Diff, Ordering, Lcs};
use std::{
env,
fs::File,
io::{self, prelude::*, BufReader}
};
fn main() -> io::Result<()> {
let mut args = env::args().skip(1);
let (source, dest) = match (args.next(), args.next()) {
(Some(source), Some(dest)) => (source, dest),
... | true |
efacd8dbf2c67f16b7b7a0942e517fc7416cd6c1 | Rust | FMhyxeee/na_alloc | /src/guarded_vec.rs | UTF-8 | 6,223 | 2.84375 | 3 | [] | no_license | use crate::{boxed::Boxed, types::*};
use std::{
fmt::{self, Debug, Formatter},
ops::{Deref, DerefMut},
};
#[derive(Clone, Eq)]
pub struct GuardedVec<T: Bytes> {
boxed: Boxed<T>,
}
pub struct Ref<'a, T: Bytes> {
boxed: &'a Boxed<T>,
}
pub struct RefMut<'a, T: Bytes> {
boxed: &'a mut Boxed<T>,
}
... | true |
f6601760ef08394ae79ae471020f93759b18128e | Rust | alistairmgreen/AdventOfCode2018 | /day23/src/lib.rs | UTF-8 | 1,587 | 3.234375 | 3 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
use regex::Regex;
use std::{fmt, num::ParseIntError, str::FromStr};
lazy_static! {
static ref INPUT_REGEX: Regex =
Regex::new(r"pos=<(-?\d+),(-?\d+),(-?\d+)>,\s+r=(-?\d+)").unwrap();
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Error {
IncorrectFormat,
Inva... | true |
48aa2b5c99fdf4986497cc197ff405a5a93f8ff4 | Rust | IPSE-TEAM/ipse-core | /client/executor/wasmtime/src/instance_wrapper/globals_snapshot.rs | UTF-8 | 3,133 | 2.59375 | 3 | [
"GPL-3.0-or-later",
"Classpath-exception-2.0",
"Apache-2.0",
"GPL-1.0-or-later",
"GPL-3.0-only"
] | permissive | // This file is part of Substrate.
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free S... | true |
f215016ee07e3ffb69cd4e4027ea88b55241a37f | Rust | justinsheehy/vertree | /src/tree.rs | UTF-8 | 30,767 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::Arc;
use std::collections::HashSet;
use std::fs::File;
use std::path::Path;
use errors::{Error, Result, ErrorKind};
use node::{Node, NodeType, Edge, Content};
use containers::{Container, Queue, Set};
use iterators::{cow_node, Iter, PathIter};
use snapshot;
use cas::{Guard, WriteOp};
/// Values included ... | true |
44f68d7d92af0e1556ce804c5ff989c8331e56c2 | Rust | KaitaoQiu/openlimits | /crates/openlimits-exchange/src/traits/exchange_account.rs | UTF-8 | 2,814 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | use async_trait::async_trait;
use crate::{
model::{
Balance, CancelAllOrdersRequest, CancelOrderRequest,
GetOrderHistoryRequest, GetOrderRequest,
OpenLimitOrderRequest, OpenMarketOrderRequest, Order,
OrderCanceled, Paginator, Trade, TradeHistoryRequest,
},
};
use super::shared:... | true |
4666c4278723f05eb9ed28bd2a7b480cf62738aa | Rust | CarlosLanderas/igdb-rs | /src/endpoints.rs | UTF-8 | 1,907 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | const BASE_URL: &str = "https://api-v3.igdb.com";
#[allow(non_camel_case_types)]
///Enum containing the implement IGDB api endpoints
pub(crate) enum Endpoint {
games,
game_engines,
companies,
websites,
artworks,
characters,
game_modes,
multiplayer_modes,
covers,
screenshots,
... | true |
026976d0ac7afd58c0b0981ad169b692770c2cc6 | Rust | seguidor777/dcoder-solutions | /medium/eric_vs_james.rs | UTF-8 | 532 | 3.40625 | 3 | [] | no_license | use std::io;
// Basic Euclidean algorithm for computing the GCD
fn gcd(x: u32, y: u32) -> u32 {
if x == 0 {
return y;
}
gcd(y % x, x)
}
fn main() {
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("cannot read input");
let v: Vec<u8> = input
... | true |
b97ff56a1bfd733b1cd6c3c5caaed4d22f46bcd1 | Rust | nabijaczleweli/poke-a-mango | /tests/ops/game_state/state.rs | UTF-8 | 5,715 | 2.640625 | 3 | [
"MIT"
] | permissive | use poke_a_mango::ops::{Difficulty, GameState};
#[test]
fn should_exit() {
assert_eq!(GameState::MainMenu.should_exit(), false);
assert_eq!(GameState::ChooseDifficulty.should_exit(), false);
assert_eq!(GameState::Playing {
difficulty: Difficulty::Easy,
score: ... | true |
d99980bbd95a66c0b2d708044bc9c42fc3cadd04 | Rust | viperscape/uuid | /src/lib.rs | UTF-8 | 30,435 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | true |
965e81bbdadfa7c70ea2aaac783fbbeb4e5d2b3d | Rust | laptou/bluez-rs | /src/lib.rs | UTF-8 | 1,315 | 2.984375 | 3 | [
"MIT"
] | permissive | //! # Management
//!
//! For managing the Bluetooth controllers on your device (pairing, discovery,
//! broadcasting, etc.), you can use the management API. This is contained
//! inside of the [`management`] module, where the central type is
//! [`management::ManagementStream`].
//!
//! # Communication
//!
//! For c... | true |
2b20feb0418d03dd6f1a7edd9ee730b7611e7b17 | Rust | cnruby/learn-rust-by-crates | /hello-borrowing/bin-hello/src/features/rs_files/for_loop_for_vec_iter.rs | UTF-8 | 1,375 | 3.046875 | 3 | [] | no_license |
pub const FOR_VEC_ITER_OK :&str = r#"pub fn main() {
let instance = vec![1u8, 2, 3];
println!("{:>13} {} {:p}", "instance raw", "=", instance.as_ptr());
print!("{:>13} {} ", "for vec ref", "=");
for item in &instance {
let ref_item: &u8 = item;
print!("{:p} ", ref_item); // OK: item IS... | true |
c4656062722e098de2d02694333ee4492890975d | Rust | sigod/codewars | /src/growth-of-a-population.rs | UTF-8 | 734 | 3.40625 | 3 | [
"MIT"
] | permissive | fn nb_year(p0: i32, percent: f64, aug: i32, p: i32)-> i32 {
let percent = 1.0 + percent / 100.0;
let mut current = p0;
let mut year = 0;
while current < p {
current = (current as f64 * percent + aug as f64) as i32;
year += 1;
}
year
}
fn dotest(p0: i32, percent: f64, aug: i32, p: i32, exp: i32) -> () {
p... | true |
73357c18f6fa7cb928103cccea3a7593eeb2b62d | Rust | MaikKlein/spire-lang | /src/ast.rs | UTF-8 | 1,477 | 3.015625 | 3 | [] | no_license | use std::collections::HashMap;
use std::sync::Arc;
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub struct Ident<'a>(pub &'a str);
#[derive(Debug, Clone, Copy)]
pub enum Value<'a> {
Text(&'a str),
Number(f64),
}
#[derive(Debug, Clone)]
pub struct Attribute<'a> {
pub ident: Ident<'a>,
pub rvalue... | true |
364781fadbd04ac20c5110c3e4da87032fe0b770 | Rust | Ralith/iced | /src/rust/iced-x86-js/src/condition_code.rs | UTF-8 | 2,306 | 2.515625 | 3 | [
"MIT"
] | permissive | /*
Copyright (C) 2018-2019 de4dot@gmail.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distr... | true |
2d93cb005a84aae4d401b9e33da3ad0520155056 | Rust | iCodeIN/rust-ptouch | /src/render/display.rs | UTF-8 | 6,184 | 3.234375 | 3 | [] | no_license | //! Virtual display for render support
// Rust PTouch Driver / Utility
//
// https://github.com/ryankurte/rust-ptouch
// Copyright 2021 Ryan Kurte
use embedded_graphics::{
prelude::*,
pixelcolor::BinaryColor,
};
use crate::Error;
/// In memory display for drawing / rendering data
pub struct Display {
y: ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.