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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f61333e0318681033dfcb96ca8d46aba83173cae | Rust | russellb23/Peroxide_ruste | /src/operation/extra_ops.rs | UTF-8 | 2,602 | 3.484375 | 3 | [] | no_license | use std::ops::{Add, Mul, Div, Sub};
pub trait PowOps: Sized {
fn powi(&self, n: i32) -> Self;
fn powf(&self, f: f64) -> Self;
fn sqrt(&self) -> Self;
}
pub trait TrigOps: Sized {
fn sin(&self) -> Self;
fn cos(&self) -> Self;
fn tan(&self) -> Self;
fn asin(&self) -> Self;
fn acos(&self)... | true |
5575673cf5a19f0516393f4ce9e9dccd890960de | Rust | rick68/rust-trace | /libcore/iter/trait_Iterator/size_hint.rs | UTF-8 | 779 | 3.140625 | 3 | [
"MIT"
] | permissive | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if self.begin < self.end {
let ... | true |
0ad0af6ff025c68d631b3409066eb146501086bc | Rust | sgrif/crater | /src/server/auth.rs | UTF-8 | 1,680 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use hyper::header::Authorization;
use hyper::server::{Request, Response};
use server::api_types::{ApiResponse, CraterToken};
use server::http::{Context, Handler, ResponseExt, ResponseFuture};
use server::Data;
use std::sync::Arc;
enum TokenType {
Agent,
}
pub struct AuthDetails {
pub name: String,
}
pub stru... | true |
16b2312ba6cb466fb2e28f79b99bfed11f058dd3 | Rust | planet-s/strace-redox | /src/lib.rs | UTF-8 | 13,650 | 2.640625 | 3 | [
"MIT"
] | permissive | use bitflags::bitflags;
use std::{
fmt,
fs::{File, OpenOptions},
io::{self, prelude::*, Result, SeekFrom},
iter,
mem::{self, MaybeUninit},
ops::{Deref, DerefMut},
os::unix::{
fs::OpenOptionsExt,
io::AsRawFd,
},
ptr, slice,
};
mod arch;
mod kernel;
macro_rules! trace... | true |
8d05d487130767fcd2ece6fd50d0b08b0943749e | Rust | mozilla/neqo | /neqo-transport/src/connection/tests/resumption.rs | UTF-8 | 8,833 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::{
co... | true |
0c2b2ba4ebc2b6fbe98191e0e76561d1d5d74c3f | Rust | miohtama/advanced-fungible | /contract/token/src/token.rs | UTF-8 | 14,881 | 2.65625 | 3 | [] | no_license | /**
* An advanced fungible token implementation.
*
*/
use near_sdk::serde_json::{self, json};
use near_sdk::borsh::{ self, BorshDeserialize, BorshSerialize};
use near_sdk::{ env, near_bindgen, ext_contract, AccountId, Balance, Promise, StorageUsage};
use near_sdk::collections::LookupMap;
use near_sdk::json_types::U... | true |
a53d866bec8cf4e25bb3b3be79c8c0baf1a34477 | Rust | likr/atcoder | /abc218/src/bin/c.rs | UTF-8 | 1,780 | 2.71875 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
#[... | true |
e5f036bdf9ed77a096207facfe066a9bd41cb0ee | Rust | oddstr13/ublox-cellular-rs | /ublox-cellular/src/power.rs | UTF-8 | 9,619 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use core::convert::TryInto;
use atat::AtatClient;
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_time::{duration::*, Clock};
use heapless::{ArrayLength, Bucket, Pos};
use crate::{
client::Device,
command::{
mobile_control::{types::Functionality, ModuleSwitchOff, SetModuleFunctionality}... | true |
cc3f744512f8267d8ee44146a50d6ea2499bb241 | Rust | Manishearth/mathema | /src/test/mod.rs | UTF-8 | 4,448 | 2.734375 | 3 | [] | no_license | #![cfg(test)]
#[macro_use]
mod env;
mathema_test! {
new_twice is |env| {
env.assert_mathema("")
.with_args(&["new", "foo"])
.unwrap();
env.assert_mathema("")
.with_args(&["new", "foo"])
.stderr()
.contains("Failed to create directory `foo`: F... | true |
53a10b922e6534da3cc7898ad75363d0e4f3d509 | Rust | ted-burns/learn-rust | /celsius_to_fahrenheit/src/main.rs | UTF-8 | 2,012 | 3.828125 | 4 | [] | no_license | use std::io::{self, Write};
use std::fmt;
const CONVERSION_COEFFICIENT: f64 = 9.0/5.0;
const CONVERSION_CONSTANT: f64 = 32.0;
fn main() {
print!("Enter your temperature to convert: ");
io::stdout().flush().expect("Unable to flush to std out");
let mut input = String::new();
io::stdin()
.read_... | true |
562178e585bfb172063cce723bd42b48bef81a6e | Rust | cloudflare/lol-html | /examples/mixed_content_rewriter/main.rs | UTF-8 | 1,584 | 2.765625 | 3 | [
"BSD-3-Clause",
"CC-BY-SA-4.0"
] | permissive | use lol_html::html_content::Element;
use lol_html::{element, HtmlRewriter, Settings};
use std::io;
use std::io::prelude::*;
fn rewrite_url_in_attr(el: &mut Element, attr_name: &str) {
let attr = el
.get_attribute(attr_name)
.unwrap()
.replace("http://", "https://");
el.set_attribute(at... | true |
9c1d08404b530b6fbbfec3f1752616e0951f04df | Rust | iBelieve/orgmode-rs | /src/document.rs | UTF-8 | 10,809 | 2.9375 | 3 | [
"MIT"
] | permissive | use headline::Headline;
use itertools::Itertools;
use node::{Node, NodeId};
use parser::Parser;
use regex::Regex;
use section::Section;
use std::collections::HashMap;
use std::fmt;
use std::fs::File;
use std::io::Error as IoError;
use std::iter::repeat;
use std::path::{Path, PathBuf};
use timestamp::{Date, Duration, Ti... | true |
3fb237599ea339bedf24274c65d08e6bd78ada15 | Rust | virtuoushub/swc | /ecmascript/transforms/src/proposals/class_properties/used_name.rs | UTF-8 | 1,188 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use swc_atoms::JsWord;
use swc_common::{Fold, Mark, Visit, VisitWith};
use swc_ecma_ast::*;
pub(super) struct UsedNameRenamer<'a> {
pub mark: Mark,
pub used_names: &'a [JsWord],
}
noop_fold_type!(UsedNameRenamer<'_>);
impl<'a> Fold<Ident> for UsedNameRenamer<'a> {
fn fold(&mut self, ident: Ident) -> Iden... | true |
e4326e298dd8000cae5811babdf23020f4418504 | Rust | RustAudio/cpal | /src/host/wasapi/stream.rs | UTF-8 | 18,765 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use super::windows_err_to_cpal_err;
use crate::traits::StreamTrait;
use crate::{
BackendSpecificError, Data, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
PlayStreamError, SampleFormat, StreamError,
};
use std::mem;
use std::ptr;
use std::sync::mpsc::{channel, Receiver, SendError, Sender};
use std::t... | true |
b466a885a46242e081509fcdc973aa5a5fca1fc2 | Rust | cossonfork/rusty-shooter | /src/jump_pad.rs | UTF-8 | 1,639 | 2.578125 | 3 | [
"MIT"
] | permissive | use rg3d::{
core::{
algebra::Vector3,
pool::{Handle, Pool, PoolIterator},
visitor::{Visit, VisitResult, Visitor},
},
physics3d::RigidBodyHandle,
};
pub struct JumpPad {
force: Vector3<f32>,
body: RigidBodyHandle,
}
impl JumpPad {
pub fn new(shape: RigidBodyHandle, force... | true |
152dd9542cda076d759cd733c444b5336b2b03c8 | Rust | xCrypt0r/Baekjoon | /src/11/11727.rs | UTF-8 | 689 | 2.65625 | 3 | [
"MIT"
] | permissive | /**
* 11727. 2×n 타일링 2
*
* 작성자: xCrypt0r
* 언어: Rust 2018
* 사용 메모리: 13,028 KB
* 소요 시간: 4 ms
* 해결 날짜: 2020년 10월 3일
*/
macro_rules! get_line {
( $( $t: ty ),+ ) => {
{
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut iter ... | true |
58f071c4f838600285e0d233b2dc49fd19eaa63a | Rust | jduan/cosmos | /rust_sandbox/rust_sandbox/src/traits.rs | UTF-8 | 27,553 | 4.15625 | 4 | [
"MIT"
] | permissive | /// One of the great discoveries in programming is that it’s possible to write code that operates on
/// values of many different types, even types that haven’t been invented yet.
///
/// It’s called "polymorphism".
///
/// # Traits and Generics
///
/// Rust supports polymorphism with two related features: traits and g... | true |
90cb5407ee7cd45701d166c27bc544f4d91e08c0 | Rust | 18616378431/myCode | /rust/test3-50/src/main.rs | UTF-8 | 162 | 2.890625 | 3 | [] | no_license | //检测类型是否实现了Copy Trait
fn test_copy<T : Copy>(i : T) {
println!("hhh");
}
fn main() {
let a = "String".to_string();
test_copy(a);
}
| true |
2ba2c8fcce9202fcdbfa392702a217ecda4a5168 | Rust | julianandrews/adventofcode | /2020/rust/src/bin/day22.rs | UTF-8 | 4,341 | 3.359375 | 3 | [] | no_license | use std::collections::{HashSet, VecDeque};
use aoc::aoc_error::AOCError;
use aoc::utils::get_input;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
let input = get_input()?;
let (deck1, deck2) = parse_input(&input)?;
println!("Part 1 {}", part1(deck1.clone(... | true |
6a56feaac175fd44142d35ee0c30002b77a0e465 | Rust | jchv/asf-rs | /src/header/metadata_library.rs | UTF-8 | 3,072 | 2.78125 | 3 | [
"ISC"
] | permissive | use crate::{span::Span, widestr::*};
use nom::{
bytes::streaming::take,
error::ParseError,
multi::length_count,
number::streaming::{le_u16, le_u32},
IResult,
};
use std::{convert::TryInto, io::Write};
#[derive(Debug, PartialEq)]
pub struct DescriptionRecord<'a> {
pub language_list_index: u16,
... | true |
4f0ef36b5d2ace26d0fe9d56461c372a131f21f8 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/futures-util/src/stream/stream/take_until.rs | UTF-8 | 3,266 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::fmt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_project_lite::pin_project;
pin_project! {
/// Stream for the [`take_unti... | true |
c63f3f54bcd2830f4a84d162adc3e296ec4706b0 | Rust | 0x1997/gcj | /src/bin/gcj15_qr_d.rs | UTF-8 | 1,505 | 3.078125 | 3 | [] | no_license | use std::io;
fn calc(x: i32, r: i32, c: i32) -> bool {
// R: hollow
if x >= 7 {
return true;
}
// plain:
let p = r * c;
// G: cannot fill
if p % x != 0 {
return true;
}
let (g_l, g_s) = if r > c { (r, c) } else { (c, r) };
// R: can do nothing
if x <= g_s {
... | true |
0190d10aecccb9c16e6e03debb48f6ac38a5a06e | Rust | shenek/console | /src/lib.rs | UTF-8 | 2,642 | 3.21875 | 3 | [
"MIT"
] | permissive | //! console is a library for Rust that provides access to various terminal
//! features so you can build nicer looking command line interfaces. It
//! comes with various tools and utilities for working with Terminals and
//! formatting text.
//!
//! Best paired with other libraries in the family:
//!
//! * [dialoguer]... | true |
b7230e8101d8c9ed1c7cacff15a3cdee20091d5c | Rust | tg-rs/tgbot | /tests/longpoll.rs | UTF-8 | 2,747 | 2.53125 | 3 | [
"MIT"
] | permissive | use dotenv::dotenv;
use futures_util::future::BoxFuture;
use mockito::{mock, server_url, Matcher};
use serde_json::json;
use std::{
sync::Arc,
time::{Duration, Instant},
};
use tgbot::{longpoll::LongPoll, types::Update, Api, UpdateHandler};
use tokio::{spawn, sync::Mutex, time::sleep};
struct Handler {
upd... | true |
d269001f2beec28ee1e732e2b8ae40a2a8d075f0 | Rust | sm-Fifteen/openmpt-rs | /src/module/current.rs | UTF-8 | 7,304 | 3.1875 | 3 | [] | no_license | //! Definitions for all methods used to set and query
//! the current state of the module
use super::Module;
use openmpt_sys;
use std::os::raw::*;
impl Module {
/// Select a sub-song from a multi-song module.
///
/// ### Parameters
/// * `subsong_num` : Index of the sub-song. -1 plays all sub-songs consecutively... | true |
56d77166893c79986abc842560756589a64e783a | Rust | YetSiawYeung/advent_of_code_2019 | /src/day11.rs | UTF-8 | 4,100 | 3.328125 | 3 | [
"MIT"
] | permissive | use crate::utils::IntcodeMachine;
use std::{collections::HashSet, num::ParseIntError};
const GRID_LENGTH: usize = 200;
pub fn painted_at_least_once() -> Result<usize, ParseIntError> {
// Part A
let mut input = include_str!("../input/day11.txt")
.split(',')
.map(|x| x.trim().parse())
.c... | true |
9a43dd7dd2ba9270be824e56e7333a4eb063e0af | Rust | denysvitali/aoc-2020 | /days/dec1/src/test/mod.rs | UTF-8 | 1,836 | 2.796875 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod tests {
use crate::{solve_puzzle, get_ints, solve_puzzle_2};
use std::io::Error;
use utils::get_file;
#[test]
fn test_get_ints() -> Result<(), Error> {
let ints = get_ints(&get_file(file!(), "1.txt"));
assert_eq!(vec!(1721, 979, 366, 299, 675, 1456), ints?);
... | true |
ebe745cfdd385bf2d2f2a5618c840d7ba3489878 | Rust | zTgx/hoopsearch | /src/http/routers/search.rs | UTF-8 | 1,684 | 2.8125 | 3 | [] | no_license | use actix_web::{web, HttpResponse, Result};
use crate::http::response::ResponseBody;
use crate::http::error::ResponseError;
use crate::http::data::Data;
use serde::{Deserialize, Serialize};
extern crate image;
extern crate img_hash;
use img_hash::{HasherConfig, HashAlg};
use image::{ImageFormat, GenericImageV... | true |
1fee0f017b7689ceaf52f206c96b711063222167 | Rust | Drakulix/taskqueue | /src/queue/serial.rs | UTF-8 | 16,610 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2016 taskqueue developers
//
// 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 ... | true |
83cae42ab266cd90e2950330b9f9a45a8777d798 | Rust | f4z3r/coding_practice | /rust/src/chapter1_6.rs | UTF-8 | 2,361 | 4.03125 | 4 | [] | no_license | //! Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the
//! image by 90 degrees. Can you do this in place?
/// Iterate through a fourth of the image and rotate by exchanging the 4 pixels that will be rotated.
fn rotate(image: &mut Vec<Vec<u32>>) {
// ... | true |
e553fa431fd20d2600f7a6d370146e91eca791b4 | Rust | DaanA32/mesh-generation | /src/meshes/polymesh.rs | UTF-8 | 6,147 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use nalgebra::base::{Vector3, Vector2};
use std::fs::File;
use std::io::prelude::*;
pub struct PolyMesh {
pub num_vertices: u32,
pub vertices: Vec<Vector3<f64>>,
pub faces: Vec<u32>,
pub st: Vec<Vector2<f64>>,
pub normals: Vec<Vector3<f64>>,
pub num_faces: u32,
pub face_array: Vec<u32>,
}
... | true |
9e0a8fe4801a8060f522b7f0fd549730981ab4cf | Rust | andysalerno/reversi_rs | /lib_reversi/src/reversi_gamestate.rs | UTF-8 | 22,285 | 3.15625 | 3 | [
"MIT"
] | permissive | use crate::util::{opponent, BoardDirectionIter};
use crate::{
reversi_board::board_directions, Board, BoardPosition, Directions, ReversiPiece,
ReversiPlayerAction, BOARD_SIZE,
};
use lib_boardgame::{GameState, PlayerColor};
use std::fmt;
#[derive(Clone)]
pub struct ReversiState {
/// The underlying 2d arra... | true |
c7d6eb7dbc3a1b70a95f42a3e189f820928f3680 | Rust | masonium/grr-util | /grr-util/src/image_manager.rs | UTF-8 | 9,486 | 2.875 | 3 | [] | no_license | //! Manager for images, image views, and samplers
use crate::image_format::*;
use slotmap::{new_key_type, DenseSlotMap};
use thiserror::Error;
new_key_type! {
pub struct ImageId;
}
new_key_type! {
pub struct ImageViewId;
}
/// Internal structure information for an image.
struct Image {
handle: grr::Image... | true |
41c2d0369841c685192f919d128b2599d5af4437 | Rust | onefrankguy/chifir | /src/computer.rs | UTF-8 | 23,170 | 3.5 | 4 | [
"MIT"
] | permissive | //! A virtual computer for executing bytecode.
use termion;
use super::sixel;
use std::io::{self, Read, Write, Cursor};
use std::marker::Send;
use std::vec::Vec;
pub struct Computer {
memory: Vec<u32>,
counter: u32,
input: Option<Box<Read + Send>>,
output: Option<Box<Write + Send>>,
keyboard: Opt... | true |
bf2c40af1ecfeb991fdacd95108d2bd798f6eb7e | Rust | danbev/learning-rust | /src/infallible.rs | UTF-8 | 380 | 3.453125 | 3 | [] | no_license | use std::convert::Infallible;
trait Something {
type Error;
fn doit(&self) -> Result<i32, Self::Error>;
}
struct S { }
impl Something for S {
type Error = Infallible;
fn doit(&self) -> Result<i32, Self::Error> {
Ok(10)
}
}
fn main() {
println!("Infallible example");
let s = S{}... | true |
f94858f3e9106949e22e8c5ea1e646c5d873f4ad | Rust | dirvine/sandbox | /neat/brain/src/phenotype.rs | UTF-8 | 1,196 | 2.609375 | 3 | [] | no_license | use Edge;
use NeuronType;
use petgraph::{Directed, graphmap};
/// Mix really of genotype and phenotype
#[allow(unused)]
pub struct Phenotype {
genome: graphmap::GraphMap<NeuronType, Edge, Directed>,
}
#[allow(unused)]
impl Phenotype {
fn new(inputs: NeuronType) {}
fn set_inputs(&mut self, inputs: Vec<i64... | true |
8a8dafd51cc862bd08c4492e515d40ce60d58de9 | Rust | vadhri/exercism-rust | /spiral-matrix/src/lib.rs | UTF-8 | 1,655 | 3.3125 | 3 | [] | no_license | #[derive(PartialOrd, PartialEq, Debug, Clone)]
pub struct Point {
x: usize,
y: usize,
}
pub fn spiral_matrix(input_size: u32) -> Vec<Vec<u32>> {
let size: usize = input_size as usize;
let no_of_layers: usize = (match size {
x if x % 2 == 0 => x / 2,
_ => size / 2 + 1
}) as u... | true |
6f38e82a67b47e8143082007af2485cfe2d59a69 | Rust | dmvict/wTools | /rust/test/options/all/basic_only_test.rs | UTF-8 | 2,097 | 2.546875 | 3 | [
"MIT"
] | permissive |
use test_tools::exposed::*;
//
tests_impls!
{
#[ test ]
fn basic()
{
// test.case( "former + form()" );
let got = split::former().src( "abc" ).delimeter( "b" ).form();
let exp = split::Options
{
src : "abc",
delimeter : "b",
left : true,
};
a_id!( got, exp );
// ... | true |
579c4b4d1fd427f03786cfa4da5c0d2dacea4bb5 | Rust | richardanaya/lazywrite | /src/lambdas/lazywrite/src/lazywrite.rs | UTF-8 | 648 | 2.546875 | 3 | [
"MIT"
] | permissive | use diesel::dsl::sql_query;
use diesel::pg::PgConnection;
use diesel::sql_types::*;
use diesel::RunQueryDsl;
use failure::Error;
use serde_json;
#[derive(QueryableByName)]
struct Movie {
#[sql_type = "Text"]
title: String,
}
pub struct Controller<'a> {
pub connection: &'a PgConnection,
}
impl<'a> Control... | true |
149b0c7d8ff1e33afac6b8ef4a361572dcf42cc1 | Rust | yuushimizu/coord-rs | /tests/map/mod.rs | UTF-8 | 1,032 | 3.234375 | 3 | [] | no_license | use coord::prelude::*;
#[test]
fn map_test() {
assert_eq!(Point::new(6, 14), Point::new(3, 7).map(|n| n * 2));
}
#[test]
fn map_to_other_type() {
assert_eq!(Size::new(6, 14), Point::new(3, 7).map(|n| n * 2));
}
#[test]
fn map_to_rect() {
assert_eq!(
Rect::new(Point::new(1, 2), Size::new(10, 20)),... | true |
eef49d3abf7b5c6e45c268b3168f893610354aa3 | Rust | conradkleinespel/rooster | /src/generate.rs | UTF-8 | 3,902 | 3.4375 | 3 | [
"Apache-2.0"
] | permissive | use rand::{rngs::OsRng, Rng};
use rclio::CliInputOutput;
use rclio::OutputType;
use rtoolbox::safe_string::SafeString;
use std::io::Result as IoResult;
fn generate_password(alnum: bool, len: usize) -> IoResult<SafeString> {
let mut password_as_string = String::new();
let mut rng = OsRng::default();
for _ i... | true |
0932ddc4e000534fac70a3f868e5e4e6a45bc6db | Rust | zombodb/zombodb | /src/query_dsl/misc.rs | UTF-8 | 6,567 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | //! This mod is to...
//! https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
//!
//!Returns documents that contain terms matching a wildcard pattern.
#[pgrx::pg_schema]
mod pg_catalog {
use pgrx::*;
use serde::*;
#[allow(non_camel_case_types)]
#[derive(Postgr... | true |
01ba80481d283a5a6ba6579b41b18e968ead39c3 | Rust | mojurasu/eikthyrnir | /chaotica/src/main.rs | UTF-8 | 768 | 2.890625 | 3 | [] | no_license | use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
mod subcommands;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
enum Args {
/// Relabel the worlds to their filename
Relabel {
/// List of worlds to rename
files: Vec<PathBuf>
},
/// Combined... | true |
670b1cea67bfc5db6871635ce2feb40f15f4a791 | Rust | 1aim/DELETE-THIS-mail-render-template-engine | /src/tera/mod.rs | UTF-8 | 3,460 | 2.65625 | 3 | [] | no_license | use tera_crate::{Tera, TesterFn, FilterFn, GlobalFn};
use serde::Serialize;
use ::traits::{RenderEngine, RenderEngineBase, AdditionalCIds};
use ::spec::{TemplateSpec, SubTemplateSpec, TemplateSource};
use self::error::TeraError;
pub mod error;
pub struct TeraRenderEngine {
tera: Tera
}
impl TeraRenderEngine {
... | true |
8da2353ea0048775d046192627125b9a95723fa5 | Rust | montaglue/concurrent_hash_table | /src/core/bin_entry/tree_node.rs | UTF-8 | 10,652 | 2.75 | 3 | [] | no_license | use std::{
borrow::Borrow,
sync::atomic::{AtomicBool, Ordering},
};
use crossbeam_epoch::{Atomic, Guard, Shared};
use crate::core::node::Node;
use super::BinEntry;
#[derive(Debug)]
pub struct TreeNode<K, V> {
pub node: Node<K, V>,
pub parent: Atomic<BinEntry<K, V>>,
pub left: Atomic<BinEntry<K, ... | true |
bf7a3b901bd2b85562a298833fbab089e82acbfc | Rust | zokugun/highlight-examples | /rust/example.rs | UTF-8 | 1,531 | 3.375 | 3 | [
"MIT"
] | permissive | //! Header comment
/**
* example.rs
* Version 1.0.0
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
**/
//! Comments
// Single line comment
/// Doc comments
/* Multiline
comment */
//! Strings
'C'; '\''; '\n'; '\u7FFF'; // Characters
"foo \"bar\" baz"; // String
r##"foo ... | true |
70636ca2fe192b560cd9507142e068bb720aeaa3 | Rust | NiravSurajlal/Rust_Projects | /Chapter_8/ch8_01/src/main.rs | UTF-8 | 773 | 3.828125 | 4 | [] | no_license | fn main() {
// infer type, or can use let v: Vec<i32> = Vec::new();
let v = vec![1, 2, 3, 4, 5];
// third is a pointer type that points to the location in memory where v[2] is stored
let third: &i32 = &v[2];
println!("Third element is {}", third);
match v.get(2){
Some(third) => println!... | true |
d2d168cd5914d15e5366e3bf05327d562f3e55ed | Rust | pklazy/lpc54628-rust | /src/pint/cienf.rs | UTF-8 | 1,487 | 2.78125 | 3 | [] | no_license | #[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CIENF {
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::... | true |
009c30eee45a917bf8b42324a340baeb7fabce60 | Rust | YoshikawaMasashi/toid | /src/data/wave/parsed/data.rs | UTF-8 | 584 | 2.765625 | 3 | [] | no_license | use super::super::super::riff::{RiffChunk, RiffData};
pub struct DataChunk {
pub data: Vec<u8>,
}
impl std::fmt::Display for DataChunk {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "***DataChunk***\n")?;
Ok(())
}
}
pub fn convert_chunk_to_data_chunk(chunk: ... | true |
fd88c59844e1a326eb8fbf589bbd60f6d3065384 | Rust | jonhoo/read-rust | /src/bin/toot.rs | UTF-8 | 4,167 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate failure;
extern crate getopts;
extern crate mammut;
extern crate read_rust;
extern crate serde;
extern crate serde_json;
extern crate uuid;
use failure::Error;
use getopts::Options;
use mammut::apps::{AppBuilder, Scopes};
use mammut::{Data, Mastodon, Registration, StatusBuilder};
use read_rust::categorie... | true |
ce41cc312da2ba9f30e2285395fc4e5a14670756 | Rust | winslis2/rust | /learn_var/src/main.rs | UTF-8 | 475 | 3.40625 | 3 | [] | no_license |
const MAX_POINT: u32 = 1000;
fn main() {
//变量定义
//定义变量如果没有加mut,是不可变的,加了mut才可以修改
let a = 1;
let mut b: u64 = 1;//类型也可以自动推导
println!("b={}",b);
b = 2;
println!("a={}",a);
println!("b={}",b);
println!("Hello, world!");
//2、隐藏性,把前面同名的隐藏
let b: f32 = 1.1;
println!("b={}",... | true |
e30dba138765340d392118024d3c86c486eed3fd | Rust | zaeleus/noodles | /noodles-bcf/src/lazy/record/filters.rs | UTF-8 | 2,705 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::io;
use noodles_vcf as vcf;
use crate::header::string_maps::StringStringMap;
/// BCF record filters.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Filters(Vec<usize>);
impl Filters {
/// Converts BCF record filters to VCF record filters.
///
/// # Examples
///
/// ```
/... | true |
122c5a92f6515f86cc42c9acf2d2215cc5d1eed9 | Rust | flyingw/umbrella | /src/hash512.rs | UTF-8 | 1,437 | 3.21875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-mit-taylor-variant"
] | permissive | use std::ops::{Index, IndexMut};
use core::slice::SliceIndex;
// #[derive(Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Hash512([u8;64]);
impl Hash512 {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
#[inline]
pub fn as_bytes_mut(&mut self) -> &mut [u8] {
&mut self.0
}
// pub f... | true |
cbfb518dc0ab79c6fd02ca884ecead67fda64fae | Rust | lineCode/rxRust | /src/subscription.rs | UTF-8 | 1,423 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::sync::{Arc, Mutex};
/// Subscription returns from `Observable.subscribe(Subscriber)` to allow
/// unsubscribing.
pub trait Subscription {
/// This allows deregistering an stream before it has finished receiving allo
/// events (i.e. before onCompleted is called).
fn unsubscribe(&mut self);
}
struct I... | true |
69840c0b274b4d138e8096381a1a6c6b95de8040 | Rust | Diggsey/c_fixed_string-rs | /src/lib.rs | UTF-8 | 15,591 | 3.40625 | 3 | [] | no_license | //! The goal of this crate is to provide a safe wrapper around the notion of
//! a C-style string with a predefined maximum length, known as the *limit*.
//!
//! CFixedString and CFixedStr are the owning and non-owning variants
//! respectively.
extern crate memchr;
use std::os::raw::c_char;
use std::{slice, str, fmt... | true |
2ef5ba2f025946ec327e8bec15faaa3d83bcd983 | Rust | ObliqueMotion/rust-advent-of-code-2019 | /src/day06.rs | UTF-8 | 1,584 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
static INPUT: &str = include_str!("../inputs/day06");
type Object = &'static str;
type OrbitMap = HashMap<Object, Object>;
type CountMap = HashMap<Object, usize>;
fn map_orbits() -> OrbitMap {
INPUT.lines().map(|line| (&line[4..], &line[..3])).collect()
}
fn orbit_count(object: Ob... | true |
923ee52d0410d50914bd49be2b635ae58fff93f5 | Rust | gobanos/advent-of-code-2017 | /src/day6.rs | UTF-8 | 4,753 | 3.625 | 4 | [] | no_license | use std::collections::HashSet;
use std::collections::HashMap;
pub fn part1(input: &str) -> u32 {
let mut input = input
.split_whitespace()
.filter_map(|c| c.parse::<usize>().ok())
.collect::<Vec<_>>();
let mut states = HashSet::new();
for i in 1.. {
reallocate(&mut input);... | true |
80a85890f66e5a5520e567f775ac6a1881d437e5 | Rust | njeisecke/umya-spreadsheet | /src/structs/theme.rs | UTF-8 | 1,699 | 3.125 | 3 | [
"MIT"
] | permissive | #[derive(Default, Debug)]
pub struct Theme {
theme_name: String,
color_scheme_name: String,
color_map: Vec<String>,
}
impl Theme {
pub fn get_theme_name(&self)-> &str {
&self.theme_name
}
pub(crate) fn set_theme_name<S: Into<String>>(&mut self, value:S) {
self.theme_name = value.... | true |
8a755c550a81523d97c8bf5804ef79b7d548b40c | Rust | buildfoundation/mainframer | /src/sync.rs | UTF-8 | 10,008 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use std::sync::mpsc::TryRecvError::*;
use std::thread;
use std::time::{Duration, Instant};
use bus::BusReader;
use crossbeam_channel::unbounded;
use crossbeam_channel::Receiver;
use crossbeam_channel::Sender;
use serde::Deserialize;
use crate::co... | true |
1d1c582dd34b8cc51cd1c59c655a98cbbead0e35 | Rust | Bert-Proesmans/medici | /medici_core/src/prefab/prototype.rs | UTF-8 | 2,863 | 2.796875 | 3 | [
"MIT"
] | permissive | #![value_from_type(ProtoItem)]
//! Module containing standard prototypes.
//!
//! The defined prototypes can be implemented in derived crates.
use error::custom_type::InvalidEntityMutUnwrap;
use function::Entity;
use marker;
use prefab::entity::Entity as EntityPrefab;
/// Prototype for game behaviour specifically ta... | true |
b40789a0d777c553c48d0186a1350e39971ac365 | Rust | JakeHuneau/google-translate-cli | /src/main.rs | UTF-8 | 7,015 | 2.796875 | 3 | [] | no_license | use regex::Regex;
use reqwest;
use serde::Deserialize;
use std::collections::HashMap;
use std::env;
use std::process::exit;
// CLI inputs
struct Input {
input_language: String,
output_language: String,
text: String,
}
// For deserializing API response from google
#[allow(non_snake_case)]
#[derive(Deserial... | true |
ad723244f9b48ce75ceeaf58f5c0948c90d46daf | Rust | abhro/rust-book | /test_demos/src/lib.rs | UTF-8 | 1,022 | 4.21875 | 4 | [] | no_license | pub fn add_two(a: i32) -> i32 {
a + 2
}
pub fn greeting(name: &str) -> String {
format!("Hello {}!", name)
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() -> Result<(), String> {
if 2 + 2 == 4 {
Ok(())
}
else {
Err(String::from("two plus two does not eq... | true |
da69c7a07606e3bcb7245bb2317cb63654d7c190 | Rust | iCodeIN/utreexo | /src/forest.rs | UTF-8 | 7,587 | 3.15625 | 3 | [
"MIT"
] | permissive | use alloc::vec::Vec;
#[cfg(feature = "serde-1")]
use serde::{Deserialize, Serialize};
use crate::{hash_leaf, merge, Direction, Proof, Prover, Tree, Utreexo};
/// Merkle forest
#[derive(Debug, Default, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde-1", derive(Serialize, Deserialize))]
pub struct MemoryForest(Vec<... | true |
3d4becd98b8dbad0f3cd6efe0d6ac831f1b44751 | Rust | wschella/rstat | /src/params/count.rs | UTF-8 | 817 | 2.5625 | 3 | [
"MIT"
] | permissive | use num::{Unsigned, Integer};
use std::fmt::{Debug, Display};
use super::{Param, constraints::{NonNegative, Constraints, UnsatisfiedConstraintError}};
#[cfg_attr(any(feature = "test", feature = "serde"), derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy)]
pub struct Count<T: Integer + Unsigned>(pub T);
imp... | true |
06f4389a6c5a00d459f54500414068b19d8d1818 | Rust | nilsso/ray-tracing-rs | /src/world.rs | UTF-8 | 1,682 | 2.984375 | 3 | [] | no_license | //! Ray tracing world encapsulation.
use crate::{Camera, Collidable, Color, Vec3};
use rand::{Rng, RngCore};
/// Ray tracing world encapsulation.
pub struct World {
sky: Vec3,
collidables: Vec<Box<dyn Collidable>>,
t_min: f64,
t_max: f64,
max_depth: usize,
samples: usize,
}
impl World {
p... | true |
334634b1b026b424564610a8efc35cf5909d93b0 | Rust | pspaul/aoc-2020 | /src/day11.rs | UTF-8 | 5,229 | 3.265625 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
use std::fmt::{Display, Formatter, Write};
use core::fmt;
#[derive(Copy, Clone, Eq, PartialEq)]
enum Seat {
Floor,
Empty,
Occupied,
}
impl Display for Seat {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Seat::Floor ... | true |
359fa8dd7e5f15440a42444de17f815d85c8987c | Rust | buckle2000/euler-solutions | /src/002.rs | UTF-8 | 434 | 3.25 | 3 | [] | no_license | /// ans = 4613732
struct Fib(usize, usize);
impl Iterator for Fib {
type Item = usize;
fn next(&mut self) -> Option<Self::Item> {
*self = Fib(self.1, self.0 + self.1);
Some(self.1)
}
}
fn main() {
let mut ans = 0;
let fib = Fib(0, 1);
for x in fib {
if x > 4000000 {
... | true |
55fbf01a1f3d6cafc6037adcfeb16f9177b1fd1c | Rust | julianandrews/adventofcode | /2020/rust/src/bin/day01.rs | UTF-8 | 1,733 | 3.28125 | 3 | [] | no_license | use aoc::aoc_error::AOCError;
use aoc::utils::{get_input, parse_fields};
use itertools::Itertools;
use std::collections::HashSet;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
let input = get_input()?;
let entries = parse_fields(input.trim(), '\n')?;
print... | true |
2a93f38acda4b6c13c858f095bf0bdd080df0775 | Rust | lloydmeta/aoc2017-rs | /src/day_2.rs | UTF-8 | 1,659 | 3.265625 | 3 | [] | no_license | const DAY_2_INPUT: &str = include_str!("../data/day_2_input");
pub fn run() -> Result<(), &'static str> {
println!("*** Day 2: Corruption Checksum ***");
println!("Input: {}", DAY_2_INPUT);
println!("Solution: {}\n", checksum(DAY_2_INPUT));
Ok(())
}
fn checksum(s: &str) -> isize {
let m = string_... | true |
c13ee3aa3e4654e3e4f76b2fecae68e624cb01e6 | Rust | Shock-1/teensy4-rs | /imxrt1062-pac/imxrt1062-pwm1/src/fctrl0.rs | UTF-8 | 11,313 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[doc = "Reader of register FCTRL0"]
pub type R = crate::R<u16, super::FCTRL0>;
#[doc = "Writer for register FCTRL0"]
pub type W = crate::W<u16, super::FCTRL0>;
#[doc = "Register FCTRL0 `reset()`'s with value 0"]
impl crate::ResetValue for super::FCTRL0 {
type Type = u16;
#[inline(always)]
fn reset_value() ... | true |
01f7e2930269cf9067d643113f729e3aa599f14c | Rust | sergiuchuckmisha/rust_sia_api | /src/servant/mod.rs | UTF-8 | 1,914 | 2.9375 | 3 | [
"MIT"
] | permissive | //routing table is here
extern crate futures;
extern crate hyper;
use self::futures::future;
use self::hyper::rt::{Future};
use self::hyper::service::service_fn;
use self::hyper::{Body, Method, Request, Response, Server, StatusCode};
/// We need to return different futures depending on the route matched,
/// and w... | true |
31e9c5512cc7b9d609f60f6639987b47d6a00171 | Rust | seikichi/exercism | /rust/anagram/src/lib.rs | UTF-8 | 582 | 3.0625 | 3 | [] | no_license | use std::collections::HashSet;
pub fn anagrams_for<'a>(word: &str, possible_anagrams: &'a [&str]) -> HashSet<&'a str> {
let mut set = HashSet::new();
let lowercase_word = word.to_lowercase();
let mut v = lowercase_word.chars().collect::<Vec<_>>();
v.sort();
for &p in possible_anagrams {
l... | true |
3d747f949ee48a3aaf65ac59c24ad4eb063c3a50 | Rust | Others/turbulence | /src/thread_rng.rs | UTF-8 | 1,676 | 2.796875 | 3 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
use super::{Rng, StdRng};
pub fn thread_rng() -> ThreadRng {
thread_local! {
static THREAD_RNG_KEY: Rc<RefCell<StdRng>> = Rc::new(RefCell::new(super::rng()))
}
ThreadRng{
inner: THREAD_RNG_KEY.with(|r| r.clone())
}
}
pub struct ThreadRng {
... | true |
3f69b03d1f8822d91604bb29641a9cd253b0a970 | Rust | pramoth/rvemu | /src/memory.rs | UTF-8 | 2,507 | 3.328125 | 3 | [
"MIT"
] | permissive | pub struct Memory {
pub dram: Vec<u8>,
}
impl Memory {
pub fn new() -> Memory {
Memory {
// Default memory size is 2048MB.
dram: vec![0; 2048 * 1000 * 1000],
}
}
pub fn len(&self) -> usize {
self.dram.len()
}
pub fn set_binary(&mut self, binary:... | true |
903461cbd93e4edf4e449133d7ba9ec0eccaaa8b | Rust | alanhoff/rust-endless-jumper | /src/engine.rs | UTF-8 | 6,074 | 2.65625 | 3 | [
"ISC"
] | permissive | #![allow(unused_assignments)]
extern crate sdl2;
extern crate rand;
use std::fmt;
use std::collections::HashMap;
use std::time::{Instant, Duration};
use std::thread;
use self::sdl2::event::Event;
use self::sdl2::render::Renderer;
use self::sdl2::image::{INIT_PNG, INIT_JPG};
use self::sdl2::mixer::{INIT_FLAC, AUDIO_S1... | true |
5470459946fb6d0f2e2306d39c45e2dd2bb68293 | Rust | RicoGit/rust-alg | /src/leetcode/middle_of_linked_list.rs | UTF-8 | 2,760 | 3.765625 | 4 | [] | no_license | //! 876. Middle of the Linked List
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
fn new_list(values... | true |
50109d257a8fb870f638d8d3bb44af7b103701e1 | Rust | rustkas/error-index | /main_tests/tests/e0389.rs | UTF-8 | 1,688 | 3.515625 | 4 | [
"MIT"
] | permissive | /*
An attempt was made to mutate data using a non-mutable reference. This commonly occurs when attempting
to assign to a non-mutable reference of a mutable reference (&(&mut T)).
*/
// cargo test --test e0389 with_error1 -- --nocapture
// cargo test --test e0389 without_error1 -- --nocapture
#[allow(dead_code)]
#[cfg(... | true |
c15d15826494e9187fedf18b7b4aff564307a270 | Rust | radonc0de/aoc19 | /universal_orbit_map/src/main.rs | UTF-8 | 2,615 | 3.265625 | 3 | [] | no_license | use std::fs;
fn main() {
let file = fs::read_to_string("puzzle_input")
.expect("Couldn't read file");
let orbits: Vec<&str> = file.split_whitespace().collect();
println!("{:?}", orbits);
let orbits_data = ind_orbits(orbits);
println!("Total orbits = {}", orbits_data.0);
pri... | true |
4e8fbbea9a88986000c0f569e3a6fd297c69779f | Rust | prz23/zinc | /zandbox/src/response.rs | UTF-8 | 1,887 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The Zandbox server daemon response.
//!
use std::marker::PhantomData;
use actix_web::http::StatusCode;
use actix_web::HttpRequest;
use actix_web::HttpResponse;
use actix_web::Responder;
use futures::future;
use serde::Serialize;
///
/// The Zandbox server daemon response.
///
#[derive(Debug, Serialize)]
pub ... | true |
c346a3fdaa990e9ce6fa55198d0f45553bf83d2d | Rust | bruntonspall/adventofcode | /2021-rust/day1/src/lib.rs | UTF-8 | 1,538 | 3.546875 | 4 | [] | no_license | pub fn parsenumbers(s: String) -> Vec<i32> {
return s.lines().map(|a|a.trim().parse().expect("Expected a number")).collect();
}
pub fn count_increases(numbers: Vec<i32>) -> usize {
return numbers.iter()
.zip(numbers.iter().skip(1))
.filter(|(a, b)| b>a)
.count();
}
pub fn create_slidin... | true |
6aac26fa54e31aff914344d95511e9ad43dff52e | Rust | BenBergman/euler | /rust/0002.rs | UTF-8 | 1,035 | 3.46875 | 3 | [] | no_license | #[cfg(not(test))]
fn main() {
for i in even_fibonacci_numbers_under_four_million() {
println!("{}", i);
}
println!("sum: {}", sum_of_even_fibonacci_numbers_under_four_million());
}
fn sum_of_even_fibonacci_numbers_under_four_million() -> u32{
even_fibonacci_numbers_under_four_million()
... | true |
3bdf58ffdeef3754de674965aec05cc5ded50062 | Rust | claucece/openmls | /src/messages/proposals.rs | UTF-8 | 19,224 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::ciphersuite::*;
use crate::codec::*;
use crate::config::ProtocolVersion;
use crate::extensions::Extension;
use crate::framing::*;
use crate::group::GroupId;
use crate::key_packages::*;
use crate::schedule::psk::*;
use crate::tree::index::*;
use serde::{Deserialize, Serialize};
use std::collections::{hash_ma... | true |
fca8eeee72e02a8c9475af76442b6f21efa17771 | Rust | AndrewTweddle/CodingExercises | /AdventOfCode/aoc2021/src/bin/day9_problem2.rs | UTF-8 | 2,834 | 3.28125 | 3 | [] | no_license | use std::collections::BinaryHeap;
use std::fs::File;
use std::io::{BufRead, BufReader};
type VisitedGrid = Vec<Vec<bool>>;
type Pos = (usize, usize);
fn main() {
let input_file = File::open("data/day9_input").unwrap();
let br = BufReader::new(input_file);
let mut visited_grid: VisitedGrid = br
.li... | true |
4d1edc943ff087a05cdf8641dbfe880079aa53f1 | Rust | sfackler/streaming-iterator | /src/slice.rs | UTF-8 | 5,149 | 3.3125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
DoubleEndedStreamingIterator, DoubleEndedStreamingIteratorMut, StreamingIterator,
StreamingIteratorMut,
};
use core::mem;
use core::num::NonZeroUsize;
/// Creates an iterator over all contiguous windows of length `size` in a mutable `slice`.
///
/// The windows overlap and may be mutated via `Str... | true |
a8a087d4f416e67450e3d6e9410895376f8933a5 | Rust | aschaeffer/rust-ecs-poc | /src/model/reactive_relation_instance.rs | UTF-8 | 6,997 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::model::{ReactivePropertyInstance, ReactiveEntityInstance, RelationInstance};
use indradb::{EdgeProperties, EdgeKey, Type};
use std::collections::HashMap;
use uuid::Uuid;
use serde_json::Value;
use std::sync::Arc;
use crate::api::{PropertyInstanceGetter, PropertyInstanceSetter};
use std::ops::Deref;
/// Reac... | true |
93c2dbdda56a861ca4ec294af9b655fa6d7bae5b | Rust | rustyhorde/vergen | /vergen-pretty/src/pretty/feature/trace.rs | UTF-8 | 11,749 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2022 vergen developers
//
// 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. All files in the project carrying such notice may not be copied,
... | true |
49320880e36d8cc59aa30e4128622366dcf844b3 | Rust | gavrie/xml-rpc-rs | /src/server.rs | UTF-8 | 4,421 | 2.609375 | 3 | [
"MIT"
] | permissive | use rouille;
use serde::{Deserialize, Serialize};
use std;
use std::collections::HashMap;
use super::error::{ErrorKind, Result};
use super::xmlfmt::{error, from_params, into_params, parse, Call, Fault, Response, Value};
type Handler = Box<Fn(Vec<Value>) -> Response + Send + Sync>;
type HandlerMap = HashMap<String, Ha... | true |
ccc039a1acee3e3a56a6571f19abd4d41a28d6b4 | Rust | arvo/arvo | /src/builder/llvm_test.rs | UTF-8 | 2,083 | 2.875 | 3 | [
"MIT"
] | permissive | use super::llvm::*;
use super::super::identifier::Symbol;
use super::super::noir::*;
use super::super::noir::context::*;
#[test]
fn hello_world() {
let context = Context::new();
let mut builder = LLVMBuilder::new("test", context.clone());
let (process_hello, process_join_hello) = simple_process(vec![write... | true |
c240500830a515c799765b34b762bd68a9c07156 | Rust | ordovicia/atcoder | /ABC115/src/bin/c.rs | UTF-8 | 737 | 2.625 | 3 | [] | no_license | #![allow(unused)]
use std::{cell, cmp, collections, fmt, iter, ops};
use cell::{Cell, RefCell};
use cmp::Ordering;
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use fmt::{Debug, Display};
use ops::{
Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Neg, ... | true |
c0dfb4100e37ed4bc44761e90964f8260b2fb5a6 | Rust | tamayura-souki/ProgrammingProblems | /project_euler/problem12/src/main.rs | UTF-8 | 1,399 | 3.328125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_divisor_num() {
assert_eq!(1, divisor_num(1));
assert_eq!(2, divisor_num(3));
assert_eq!(4, divisor_num(6));
assert_eq!(4, divisor_num(10));
assert_eq!(4, divisor_num(15));
assert_eq!(4, divisor_num(21));
... | true |
7fcb8d7c0c81c24c9226a53bab6137d62fa9a858 | Rust | shilpakancharla/learning-rust | /14_02_match_operator/end/match_operator/src/main.rs | UTF-8 | 504 | 3.890625 | 4 | [] | no_license | #[derive(Debug)]
enum Shape {
Circle(f64), // radius
Rectangle(f64, f64), // width, height
Triangle(f64, f64, f64) // sides a, b, c
}
fn main() {
let my_shape = Shape::Rectangle(1.2, 3.4);
println!("my_shape is {:?}", my_shape);
match my_shape {
Shape::Circle(r) => println!("Circle wit... | true |
ac2eee53e44b04dd159123ee0d71468e3fd7d0c2 | Rust | samlet/bluecc | /entity-seed/src/meta/linq_tests.rs | UTF-8 | 1,200 | 3.578125 | 4 | [] | no_license | use functor::linq;
use functor::iter::Enumerable;
#[test]
fn try_linq() {
let x = 1..100;
let y: Vec<i32> = x.clone().map(|p| p * 2).collect();
let e: Vec<i32> = linq!(from p in x.clone(), select p * 2).collect();
assert_eq!(e, y);
}
/// https://gist.github.com/leonardo-m/6e9315a57fe9caa893472c2935e9d... | true |
357f2a6a9e5525ca5ee1f39bab8e49206286d5e7 | Rust | joshzeldin/rsq | /src/kdb.rs | UTF-8 | 18,858 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::net::TcpStream;
use std::io::{BufReader, BufWriter};
use std::io::{ErrorKind, Error, Write, Read};
use byteorder::{LittleEndian, WriteBytesExt};
use crate::KObj;
use super::header::Header;
use super::ktype::KType;
const UNSUPPORTED_TYPES: [i8;10] = [103, 104, 105, 106, 107, 108, 109, 110, 111, 112];
pub stru... | true |
2adf93a9839a1dc9cc9a4be37b896c39342b2b23 | Rust | jacklund/cryptopals_old | /src/challenges/set_1/challenge8.rs | UTF-8 | 734 | 2.8125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use crate::aes_ecb::detect_aes_ecb;
use std::fs::File;
use std::io::{BufRead, BufReader};
// Eighth cryptopals challenge - https://cryptopals.com/sets/1/challenges/8
#[test]
fn challenge8() {
let mut found: Option<String> = None;
for line in BufReader::n... | true |
32fe20231cb75efa7124c64d31922e6a8e284ca8 | Rust | amarmaduke/reducto | /src/normal.rs | UTF-8 | 4,294 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap};
use crate::tree::Tree;
use crate::strategy::Strategy;
impl Tree {
fn shift(tree : Tree, place : isize, cutoff : isize) -> Tree {
match tree {
Tree::Var(index) => {
let i = index as isize;
if i < cutoff {
Tree:... | true |
aa768b0775efbbdfc2bf21e0758424f21c2bec83 | Rust | shmup/rustmud | /src/mud/player.rs | UTF-8 | 549 | 3 | 3 | [] | no_license | use std::io::prelude::*;
use std::net::TcpStream;
use std::str::from_utf8;
pub struct Player {
pub stream: TcpStream
}
impl Player {
pub fn new(stream: TcpStream) -> Player {
return Player {
stream: stream
}
}
pub fn read(&mut self) {
let mut buffer = [0u8; 512];
... | true |
3f6845ed0c675e59ff4f0111dd5feb2452c1a672 | Rust | PrimeGoose/neon | /src/event/event_queue.rs | UTF-8 | 8,828 | 3.21875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use neon_runtime::raw::Env;
use neon_runtime::tsfn::ThreadsafeFunction;
use crate::context::{Context, TaskContext};
use crate::result::NeonResult;
type Callback = Box<dyn FnOnce(Env) + Send + 'static>;
/// Channel for scheduling Rust closures to ex... | true |
8a80ea8443fd36c2ce18111b2bf35eaa5b06529f | Rust | stpettersens/txtrevise | /rust/txtrevise/src/main.rs | UTF-8 | 4,682 | 3.09375 | 3 | [
"MIT"
] | permissive | /*
Txtrevise (rust)
Command line text editing tool
Version 1.0.0 (equivalent to Python impl. 1.1)
Copyright (c) 2015 Sam Saint-Pettersen
Released under the MIT License.
*/
extern crate clioptions;
extern crate regex;
use clioptions::CliOptions;
use regex::Regex;
use std::io::{BufRead, BufReader, W... | true |
86ea2a47d85bf29682d45a22ceb03e3fadac2d88 | Rust | tatsuya6502/promising-future | /tests/criterion.rs | UTF-8 | 3,033 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![cfg(feature = "criterion")]
#![feature(plugin)]
#![plugin(criterion_macros)]
extern crate criterion;
extern crate promising_future;
extern crate threadpool;
use std::mem;
use std::thread;
use criterion::Bencher;
use threadpool::ThreadPool;
use promising_future::{future_promise, Future};
#[criterion]
fn local_pres... | true |
1585fb51231ef9482517c560c8751d0b5c340d90 | Rust | mrnugget/dora | /dora/src/semck/enumck.rs | UTF-8 | 4,693 | 2.75 | 3 | [
"MIT"
] | permissive | use dora_parser::ast::visit::{walk_file, Visitor};
use dora_parser::ast::{Ast, Enum, File};
use crate::error::msg::SemError;
use crate::semck;
use crate::ty::BuiltinType;
use crate::vm::{EnumId, EnumVariant, NodeMap, VM};
pub fn check<'ast>(vm: &mut VM<'ast>, ast: &'ast Ast, map_enum_defs: &NodeMap<EnumId>) {
let... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.